Module ojalgo

Enum SimilarityMeasure

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<SimilarityMeasure>

    public enum SimilarityMeasure
    extends java.lang.Enum<SimilarityMeasure>
    Similarity measures quantify how alike two items are. Unlike distances (where smaller is closer), larger similarity values indicate greater affinity. Many similarities are bounded in [0,1] with 1 meaning identical, but some (e.g., correlation or dot product) can be negative or unbounded. Unless documented otherwise, similarities here are symmetric. Conversions between similarity and distance often exist via monotone transforms, but metric or kernel properties are not guaranteed by such transforms.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      BHATTACHARYYA
      Bhattacharyya coefficient for non‑negative vectors (often probability distributions): s = Σ_i sqrt(a_i b_i).
      COSINE
      Cosine similarity s = (a·b) / (||a||·||b||).
      DICE
      Sørensen–Dice coefficient: s = 2|A ∩ B| / (|A| + |B|).
      JACCARD
      Jaccard similarity for sets or binary vectors: s = |A ∩ B| / |A ∪ B|.
      LINEAR
      Linear similarity s = a·b (dot product).
      OVERLAP
      Overlap (Szymkiewicz–Simpson) coefficient: s = |A ∩ B| / min(|A|, |B|).
      PEARSON
      Pearson correlation coefficient between two vectors, equivalent to cosine similarity after mean centering each vector.
      SIMPLE_MATCHING
      Simple matching coefficient (Sokal–Michener) for binary vectors: fraction of coordinates that match (both 0 or both 1).
      TANIMOTO
      Tanimoto (extended Jaccard) similarity for non-negative real vectors: s = (a·b) / (||a||² + ||b||² − a·b).
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SimilarityMeasure()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static SimilarityMeasure valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static SimilarityMeasure[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • COSINE

        public static final SimilarityMeasure COSINE
        Cosine similarity s = (a·b) / (||a||·||b||). Measures the angle between vectors; insensitive to uniform scaling. Range is [-1, 1] in general and [0, 1] for non-negative data.
      • PEARSON

        public static final SimilarityMeasure PEARSON
        Pearson correlation coefficient between two vectors, equivalent to cosine similarity after mean centering each vector. Range [-1, 1]; invariant to affine scaling of each vector.
      • LINEAR

        public static final SimilarityMeasure LINEAR
        Linear similarity s = a·b (dot product). Unbounded and sensitive to scale; equals the linear kernel. Useful when magnitudes carry meaning.
      • BHATTACHARYYA

        public static final SimilarityMeasure BHATTACHARYYA
        Bhattacharyya coefficient for non‑negative vectors (often probability distributions): s = Σ_i sqrt(a_i b_i). Range [0, 1] when inputs are normalised to sum to 1.
      • JACCARD

        public static final SimilarityMeasure JACCARD
        Jaccard similarity for sets or binary vectors: s = |A ∩ B| / |A ∪ B|. For sparse indicator vectors it can be interpreted over the set of non-zero indices. Range [0, 1].
      • TANIMOTO

        public static final SimilarityMeasure TANIMOTO
        Tanimoto (extended Jaccard) similarity for non-negative real vectors: s = (a·b) / (||a||² + ||b||² − a·b). Reduces to Jaccard for binary vectors. Range [0, 1] when inputs are non-negative.
      • DICE

        public static final SimilarityMeasure DICE
        Sørensen–Dice coefficient: s = 2|A ∩ B| / (|A| + |B|). Closely related to Jaccard and often preferred with imbalanced set sizes. Range [0, 1].
      • OVERLAP

        public static final SimilarityMeasure OVERLAP
        Overlap (Szymkiewicz–Simpson) coefficient: s = |A ∩ B| / min(|A|, |B|). Emphasises subset relations; equals 1 when one set is contained in the other. Range [0, 1].
      • SIMPLE_MATCHING

        public static final SimilarityMeasure SIMPLE_MATCHING
        Simple matching coefficient (Sokal–Michener) for binary vectors: fraction of coordinates that match (both 0 or both 1). Equivalent to 1 − normalised Hamming distance. Range [0, 1].
    • Constructor Detail

      • SimilarityMeasure

        private SimilarityMeasure()
    • Method Detail

      • values

        public static SimilarityMeasure[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (SimilarityMeasure c : SimilarityMeasure.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static SimilarityMeasure valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null