|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.cilib.util.CosineDistanceMeasure
public class CosineDistanceMeasure
The Cosine Distance Measure (or vector dot product) is not a distance measure, but
rather a similarity metric. It is defined in:
Learning structure and concepts in data through data clustering
by Gregory James Hamerly, 2003
More positive values indicate similarity. The vector dot product is the sum of the product of each attribute from two vectors being compared. Here we use a normalized version of the metric so that the dot product is always a value between -1 and 1. The vector dot product does not measure the difference in magnitude between two vectors; only the difference in the angle between the vectors. If the (normalized) result = 1, the two vectors are collinear and pointed in the same direction, if the (normalized) result = -1, the two vectors are collinear and pointed in opposite directions, and if the (normalized) result = 0, then the two vectors are orthogonal. We can convert this similarity measure to a "distance" by subtracting it from one, which will always give a value between 0 and 2. This is the approach we follow.
Constructor Summary | |
---|---|
CosineDistanceMeasure()
|
Method Summary | ||
---|---|---|
|
distance(T x,
T y)
Calculate the "distance" (dot product) between (of) two vectors represented by Java Collection objects. |
|
|
distance(U x,
U y)
Calculate the "distance" (dot product) between (of) two vectors. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CosineDistanceMeasure()
Method Detail |
---|
public <T extends Type,U extends StructuredType<T>> double distance(U x, U y)
distance
in interface DistanceMeasure
T
- The Vector type.x
- the one vector.y
- the other vector.
IllegalArgumentException
- when the two vectors' dimension differ.public <T extends Collection<? extends Number>> double distance(T x, T y)
distance
in interface DistanceMeasure
T
- The Vector type.x
- the one Java Collection object.y
- the other Java Collection object.
IllegalArgumentException
- when the two vectors' dimension differ.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |