O
- Vector type@Reference(authors="P. Jaccard", title="\u00c9tude comparative de la distribution florale dans une portion des Alpes et des Jura", booktitle="Bulletin del la Soci\u00e9t\u00e9 Vaudoise des Sciences Naturelles") public class JaccardPrimitiveSimilarityFunction<O extends FeatureVector<?>> extends AbstractPrimitiveSimilarityFunction<O,DoubleDistance> implements NormalizedPrimitiveSimilarityFunction<O>, PrimitiveDoubleDistanceFunction<O>
|intersection|/|union|
.
We can extend this definition as follows:
|non-zero and equal attributes|/|non-zero attributes|
.
For binary vectors, this will obviously be the same quantity. However, this
version is more useful for categorical data.
Reference:
P. Jaccard
Étude comparative de la distribution florale dans une portion des Alpes et
des Jura
Bulletin del la Société Vaudoise des Sciences Naturelles
Modifier and Type | Field and Description |
---|---|
private static Double |
DOUBLE_NULL
Constants for checking null.
|
private static Integer |
INTEGER_NULL
Constants for checking null.
|
private static String |
STRING_NULL
Empty string.
|
Constructor and Description |
---|
JaccardPrimitiveSimilarityFunction()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
DoubleDistance |
distance(O o1,
O o2)
Computes the distance between two given DatabaseObjects according to this
distance function.
|
double |
doubleDistance(O o1,
O o2)
Computes the distance between two given Objects according to this distance
function.
|
double |
doubleSimilarity(O o1,
O o2)
Computes the similarity between two given Objects according to this
similarity function.
|
static double |
doubleSimilarityNumberVector(NumberVector<?> o1,
NumberVector<?> o2)
Compute Jaccard similarity for two number vectors.
|
DoubleDistance |
getDistanceFactory()
Get a distance factory.
|
SimpleTypeInformation<? super O> |
getInputTypeRestriction()
Get the input data type of the function.
|
<T extends O> |
instantiate(Relation<T> relation)
Instantiate with a representation to get the actual similarity query.
|
boolean |
isMetric()
Is this distance function metric (in particular, does it satisfy the
triangle equation?)
|
private static boolean |
isNull(Object val)
Test a value for null.
|
DoubleDistance |
similarity(O o1,
O o2)
Computes the similarity between two given DatabaseObjects according to this
similarity function.
|
isSymmetric
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isSymmetric
isSymmetric
private static final Integer INTEGER_NULL
private static final Double DOUBLE_NULL
private static final String STRING_NULL
public JaccardPrimitiveSimilarityFunction()
public double doubleSimilarity(O o1, O o2)
PrimitiveDoubleSimilarityFunction
doubleSimilarity
in interface PrimitiveDoubleSimilarityFunction<O extends FeatureVector<?>>
o1
- first Objecto2
- second Objectpublic static double doubleSimilarityNumberVector(NumberVector<?> o1, NumberVector<?> o2)
o1
- First vectoro2
- Second vectorpublic DoubleDistance similarity(O o1, O o2)
PrimitiveSimilarityFunction
similarity
in interface PrimitiveSimilarityFunction<O extends FeatureVector<?>,DoubleDistance>
similarity
in class AbstractPrimitiveSimilarityFunction<O extends FeatureVector<?>,DoubleDistance>
o1
- first DatabaseObjecto2
- second DatabaseObjectprivate static boolean isNull(Object val)
FeatureVector
instead?val
- Valuepublic DoubleDistance distance(O o1, O o2)
PrimitiveDistanceFunction
distance
in interface PrimitiveDistanceFunction<O extends FeatureVector<?>,DoubleDistance>
o1
- first DatabaseObjecto2
- second DatabaseObjectpublic double doubleDistance(O o1, O o2)
PrimitiveDoubleDistanceFunction
doubleDistance
in interface PrimitiveDoubleDistanceFunction<O extends FeatureVector<?>>
o1
- first Objecto2
- second Objectpublic boolean isMetric()
DistanceFunction
isMetric
in interface DistanceFunction<O extends FeatureVector<?>,DoubleDistance>
true
when metric.public DoubleDistance getDistanceFactory()
SimilarityFunction
getDistanceFactory
in interface DistanceFunction<O extends FeatureVector<?>,DoubleDistance>
getDistanceFactory
in interface SimilarityFunction<O extends FeatureVector<?>,DoubleDistance>
public SimpleTypeInformation<? super O> getInputTypeRestriction()
SimilarityFunction
getInputTypeRestriction
in interface DistanceFunction<O extends FeatureVector<?>,DoubleDistance>
getInputTypeRestriction
in interface PrimitiveDistanceFunction<O extends FeatureVector<?>,DoubleDistance>
getInputTypeRestriction
in interface PrimitiveSimilarityFunction<O extends FeatureVector<?>,DoubleDistance>
getInputTypeRestriction
in interface SimilarityFunction<O extends FeatureVector<?>,DoubleDistance>
getInputTypeRestriction
in class AbstractPrimitiveSimilarityFunction<O extends FeatureVector<?>,DoubleDistance>
public <T extends O> DistanceSimilarityQuery<T,DoubleDistance> instantiate(Relation<T> relation)
SimilarityFunction
instantiate
in interface DistanceFunction<O extends FeatureVector<?>,DoubleDistance>
instantiate
in interface SimilarityFunction<O extends FeatureVector<?>,DoubleDistance>
instantiate
in class AbstractPrimitiveSimilarityFunction<O extends FeatureVector<?>,DoubleDistance>
relation
- Representation to use