|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.aitools.aq.algebra.vector.functions.CosineSimilarity
public final class CosineSimilarity
A Similarity
measure for Vector
s.
The Cosine Similarity of two vectors is defined as the cosine
of the angle between them.
It is calculated as the dot product of the both vectors divided by the
multiplied euclidean norms of both.
The resulting similarity of a vector a and a vector b is
between -1 (if a equals -b * k) and 1 (if a equals b * k),
with k being a positive rational number (and thus not zero).
A value of 0 signals that the two vectors are orthogonal or at least one
of them is the null vector.
Proximity
of this measure is equal to similarity. Normalized
proximity is the proximity plus one and divided by two.
Constructor Summary | |
---|---|
CosineSimilarity()
Construct a new CosineSimilarity . |
Method Summary | |
---|---|
double |
computeNormalizedProximity(Vector v1,
Vector v2)
Compute a kind of proximity between two objects. The value returned by this method has to be between 0 (meaning they are as far away (according to the proximity measure) from each other as possible) and 1 (identical objects according to the proximity measure). |
double |
computeProximity(Vector v1,
Vector v2)
Compute a kind of proximity between two objects. |
double |
computeSimilarity(Vector v1,
Vector v2)
Compute the Similarity between two objects. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CosineSimilarity()
CosineSimilarity
.
Method Detail |
---|
public double computeSimilarity(Vector v1, Vector v2)
Similarity
Similarity
between two objects.
A higher value signals higher similarity.
computeSimilarity
in interface Similarity<Vector>
v1
- One object, to be compared to the...v2
- ...second object
public double computeProximity(Vector v1, Vector v2)
Proximity
computeProximity
in interface Proximity<Vector>
v1
- One object, to be compared to the...v2
- ...second object
public double computeNormalizedProximity(Vector v1, Vector v2)
Proximity
computeNormalizedProximity
in interface Proximity<Vector>
v1
- One object, to be compared to the...v2
- ...second object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |