@Shareable public class SignificanceWeightedVectorSimilarity extends Object implements VectorSimilarity, Serializable
SigWeightThreshold
parameter.
Significance weighting decreases the similarity between two vectors when the number of common entities between the two vectors is low. For a threshold \(S\) and key sets \(K_1\) and \(K_2\), the similarity is multipled by \[\frac{|K_1 \cap K_2|}{\mathrm{max}(|K_1 \cap K_2|, S)}\]
SigWeightThreshold
,
Serialized FormConstructor and Description |
---|
SignificanceWeightedVectorSimilarity(int thresh,
VectorSimilarity sim) |
Modifier and Type | Method and Description |
---|---|
VectorSimilarity |
getDelegate()
Get the underlying similarity (for debuggin purposes).
|
boolean |
isSparse()
Query whether this similarity function is sparse (returns 0 for vectors with
disjoint key sets).
|
boolean |
isSymmetric()
Query whether this similarity function is symmetric.
|
double |
similarity(SparseVector vec1,
SparseVector vec2)
Compute the similarity between two vectors.
|
String |
toString() |
@Inject public SignificanceWeightedVectorSimilarity(@SigWeightThreshold int thresh, VectorSimilarity sim)
public VectorSimilarity getDelegate()
public double similarity(SparseVector vec1, SparseVector vec2)
VectorSimilarity
similarity
in interface VectorSimilarity
vec1
- The left vector to compare.vec2
- The right vector to compare.public boolean isSparse()
VectorSimilarity
isSparse
in interface VectorSimilarity
true
iff VectorSimilarity.similarity(SparseVector, SparseVector)
will always return
true when applied to two vectors with no keys in common.public boolean isSymmetric()
VectorSimilarity
isSymmetric
in interface VectorSimilarity
true
if the function is symmetric.