Enum Class SimilarityMeasure

java.lang.Object
java.lang.Enum<SimilarityMeasure>
org.ojalgo.data.proximity.SimilarityMeasure
All Implemented Interfaces:
Serializable, Comparable<SimilarityMeasure>, Constable

public enum SimilarityMeasure extends 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.
  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

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

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

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

    • 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 Details

    • SimilarityMeasure

      private SimilarityMeasure()
  • Method Details

    • values

      public static SimilarityMeasure[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static SimilarityMeasure valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null