- java.lang.Object
-
- java.lang.Enum<SimilarityMeasure>
-
- org.ojalgo.data.proximity.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 BHATTACHARYYABhattacharyya coefficient for non‑negative vectors (often probability distributions): s = Σ_i sqrt(a_i b_i).COSINECosine similarity s = (a·b) / (||a||·||b||).DICESørensen–Dice coefficient: s = 2|A ∩ B| / (|A| + |B|).JACCARDJaccard similarity for sets or binary vectors: s = |A ∩ B| / |A ∪ B|.LINEARLinear similarity s = a·b (dot product).OVERLAPOverlap (Szymkiewicz–Simpson) coefficient: s = |A ∩ B| / min(|A|, |B|).PEARSONPearson correlation coefficient between two vectors, equivalent to cosine similarity after mean centering each vector.SIMPLE_MATCHINGSimple matching coefficient (Sokal–Michener) for binary vectors: fraction of coordinates that match (both 0 or both 1).TANIMOTOTanimoto (extended Jaccard) similarity for non-negative real vectors: s = (a·b) / (||a||² + ||b||² − a·b).
-
Constructor Summary
Constructors Modifier Constructor Description privateSimilarityMeasure()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SimilarityMeasurevalueOf(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.
-
-
-
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].
-
-
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 namejava.lang.NullPointerException- if the argument is null
-
-