Package com.oracle.coherence.ai.distance
Class CosineDistance<T>
java.lang.Object
com.oracle.coherence.ai.distance.AbstractDistance<T>
com.oracle.coherence.ai.distance.CosineDistance<T>
- All Implemented Interfaces:
DistanceAlgorithm<T>
,ExternalizableLite
,PortableObject
,Serializable
A
DistanceAlgorithm
that performs a cosine similarity calculation between two vectors.
Cosine similarity measures the similarity between two vectors of an inner product space.
It is measured by the cosine of the angle between two vectors and determines whether two
vectors are pointing in roughly the same direction. It is often used to measure document
similarity in text analysis.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected double
distance
(byte[] v1, byte[] v2) Calculate the distance between two Int8 (byte) vectors.protected double
distance
(float[] v1, float[] v2) Calculate the distance between two Float32 (float) vectors.protected double
Calculate the distance between two bit vectors.Methods inherited from class com.oracle.coherence.ai.distance.AbstractDistance
distance, readExternal, readExternal, writeExternal, writeExternal
-
Constructor Details
-
CosineDistance
public CosineDistance()
-
-
Method Details
-
distance
Description copied from class:AbstractDistance
Calculate the distance between two bit vectors.- Specified by:
distance
in classAbstractDistance<T>
- Parameters:
v1
- the first bit vectorv2
- the second bit vector- Returns:
- the distance between the two bit vectors
-
distance
protected double distance(byte[] v1, byte[] v2) Description copied from class:AbstractDistance
Calculate the distance between two Int8 (byte) vectors.- Specified by:
distance
in classAbstractDistance<T>
- Parameters:
v1
- the first Int8 vectorv2
- the second Int8 vector- Returns:
- the distance between the two Int8 vectors
-
distance
protected double distance(float[] v1, float[] v2) Description copied from class:AbstractDistance
Calculate the distance between two Float32 (float) vectors.- Specified by:
distance
in classAbstractDistance<T>
- Parameters:
v1
- the first Float32 vectorv2
- the second Float32 vector- Returns:
- the distance between the two Float32 vectors
-