@Reference(authors="P. Jaccard", title="Distribution de la florine alpine dans la Bassin de Dranses et dans quelques regiones voisines", booktitle="Bulletin del la Soci\u00e9t\u00e9 Vaudoise des Sciences Naturelles", url="http://data.rero.ch/01-R241574160", bibkey="journals/misc/Jaccard1902") @Alias(value="de.lmu.ifi.dbs.elki.distance.similarityfunction.JaccardPrimitiveSimilarityFunction") public class JaccardSimilarityDistanceFunction extends AbstractSetDistanceFunction<FeatureVector<?>> implements NormalizedPrimitiveSimilarityFunction<FeatureVector<?>>, NumberVectorDistanceFunction<FeatureVector<?>>, PrimitiveDistanceFunction<FeatureVector<?>>
Jaccard coefficient is commonly defined as \(\frac{A\cap B}{A\cup B}\).
We can extend this definition to non-binary vectors as follows: \(\tfrac{|\{i\mid a_i = b_i\}|}{|\{i\mid a_i = 0 \wedge b_i = 0\}|}\)
For binary vectors, this will obviously be the same quantity. However, this version is more useful for categorical data.
Reference:
P. Jaccard
Distribution de la florine alpine dans la Bassin de Dranses et dans quelques
regiones voisines
Bulletin del la Société Vaudoise des Sciences Naturelles
DOUBLE_NULL, INTEGER_NULL, STRING_NULL
Constructor and Description |
---|
JaccardSimilarityDistanceFunction()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
distance(FeatureVector<?> o1,
FeatureVector<?> o2)
Computes the distance between two given DatabaseObjects according to this
distance function.
|
double |
distance(NumberVector o1,
NumberVector o2)
Computes the distance between two given vectors according to this distance
function.
|
boolean |
equals(java.lang.Object obj) |
SimpleTypeInformation<? super FeatureVector<?>> |
getInputTypeRestriction()
Get the input data type of the function.
|
int |
hashCode() |
<T extends FeatureVector<?>> |
instantiate(Relation<T> relation)
Instantiate with a representation to get the actual similarity query.
|
boolean |
isMetric()
Is this distance function metric (satisfy the triangle inequality)
|
boolean |
isSymmetric()
Is this function symmetric?
|
double |
similarity(FeatureVector<?> o1,
FeatureVector<?> o2)
Computes the similarity between two given DatabaseObjects according to this
similarity function.
|
static double |
similarityNumberVector(NumberVector o1,
NumberVector o2)
Compute Jaccard similarity for two number vectors.
|
isNull
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
isSquared
public JaccardSimilarityDistanceFunction()
public double similarity(FeatureVector<?> o1, FeatureVector<?> o2)
PrimitiveSimilarityFunction
similarity
in interface PrimitiveSimilarityFunction<FeatureVector<?>>
o1
- first DatabaseObjecto2
- second DatabaseObjectpublic static double similarityNumberVector(NumberVector o1, NumberVector o2)
o1
- First vectoro2
- Second vectorpublic double distance(FeatureVector<?> o1, FeatureVector<?> o2)
PrimitiveDistanceFunction
distance
in interface PrimitiveDistanceFunction<FeatureVector<?>>
o1
- first DatabaseObjecto2
- second DatabaseObjectpublic double distance(NumberVector o1, NumberVector o2)
NumberVectorDistanceFunction
distance
in interface NumberVectorDistanceFunction<FeatureVector<?>>
o1
- first vectoro2
- second vectorpublic boolean isSymmetric()
SimilarityFunction
isSymmetric
in interface DistanceFunction<FeatureVector<?>>
isSymmetric
in interface SimilarityFunction<FeatureVector<?>>
true
when symmetricpublic boolean isMetric()
DistanceFunction
isMetric
in interface DistanceFunction<FeatureVector<?>>
true
when metric.public SimpleTypeInformation<? super FeatureVector<?>> getInputTypeRestriction()
SimilarityFunction
getInputTypeRestriction
in interface DistanceFunction<FeatureVector<?>>
getInputTypeRestriction
in interface PrimitiveDistanceFunction<FeatureVector<?>>
getInputTypeRestriction
in interface SimilarityFunction<FeatureVector<?>>
public <T extends FeatureVector<?>> DistanceSimilarityQuery<T> instantiate(Relation<T> relation)
SimilarityFunction
instantiate
in interface DistanceFunction<FeatureVector<?>>
instantiate
in interface PrimitiveDistanceFunction<FeatureVector<?>>
instantiate
in interface PrimitiveSimilarityFunction<FeatureVector<?>>
instantiate
in interface SimilarityFunction<FeatureVector<?>>
relation
- Representation to usepublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Copyright © 2019 ELKI Development Team. License information.