Enum Class SimilarityMeasure
- All Implemented Interfaces:
Serializable, Comparable<SimilarityMeasure>, Constable
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 ConstantsEnum ConstantDescriptionBhattacharyya 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic SimilarityMeasureReturns the enum constant of this class with the specified name.static SimilarityMeasure[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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
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
Linear similarity s = a·b (dot product). Unbounded and sensitive to scale; equals the linear kernel. Useful when magnitudes carry meaning. -
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
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
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
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
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
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
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
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 nameNullPointerException- if the argument is null
-