org.mymedialite.correlation
Class BinaryCosine
java.lang.Object
org.mymedialite.datatype.SymmetricMatrix<java.lang.Float>
org.mymedialite.correlation.CorrelationMatrix
org.mymedialite.correlation.BinaryDataCorrelationMatrix
org.mymedialite.correlation.BinaryCosine
- All Implemented Interfaces:
- IMatrix<java.lang.Float>
public final class BinaryCosine
- extends BinaryDataCorrelationMatrix
Class for storing cosine similarities.
http://en.wikipedia.org/wiki/Cosine_similarity
Constructor Summary |
BinaryCosine(int numEntities)
Creates an object of type Cosine. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BinaryCosine
public BinaryCosine(int numEntities)
- Creates an object of type Cosine.
- Parameters:
numEntities
- the number of entities
create
public static CorrelationMatrix create(IBooleanMatrix vectors)
- Creates a Cosine similarity matrix from given data.
- Parameters:
vectors
- the boolean data
- Returns:
- the similarity matrix based on the data
computeCorrelations
public void computeCorrelations(IBooleanMatrix entityData)
- Description copied from class:
BinaryDataCorrelationMatrix
- Compute the correlations from an implicit feedback, positive-only dataset.
- Specified by:
computeCorrelations
in class BinaryDataCorrelationMatrix
- Parameters:
entityData
- the implicit feedback set, rows contain the entities to correlate
computeCorrelation
public static float computeCorrelation(java.util.HashSet<java.lang.Integer> vectorI,
java.util.HashSet<java.lang.Integer> vectorJ)
- Computes the cosine similarity of two binary vectors.
- Parameters:
vectorI
- the first vectorvectorJ
- the second vector
- Returns:
- the cosine similarity between the two vectors