org.mymedialite.correlation
Class Jaccard
java.lang.Object
org.mymedialite.datatype.SymmetricMatrix<java.lang.Float>
org.mymedialite.correlation.CorrelationMatrix
org.mymedialite.correlation.BinaryDataCorrelationMatrix
org.mymedialite.correlation.Jaccard
- All Implemented Interfaces:
- IMatrix<java.lang.Float>
public final class Jaccard
- extends BinaryDataCorrelationMatrix
Class for storing and computing the Jaccard index (Tanimoto coefficient).
The Jaccard index is often also called the Tanimoto coefficient.
http://en.wikipedia.org/wiki/Jaccard_index
Constructor Summary |
Jaccard(int numEntities)
Creates an object of type Jaccard. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Jaccard
public Jaccard(int numEntities)
- Creates an object of type Jaccard.
- Parameters:
numEntities
- the number of entities
create
public static CorrelationMatrix create(IBooleanMatrix vectors)
- Creates a Jaccard index 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 Jaccard index of two binary vectors.
- Parameters:
vectorI
- the first vectorvectorJ
- the second vector
- Returns:
- the cosine similarity between the two vectors