org.mymedialite.correlation
Class Pearson

java.lang.Object
  extended by org.mymedialite.datatype.SymmetricMatrix<java.lang.Float>
      extended by org.mymedialite.correlation.CorrelationMatrix
          extended by org.mymedialite.correlation.RatingCorrelationMatrix
              extended by org.mymedialite.correlation.Pearson
All Implemented Interfaces:
IMatrix<java.lang.Float>

public class Pearson
extends RatingCorrelationMatrix

Correlation class for Pearson correlation. http://en.wikipedia.org/wiki/Pearson_correlation


Field Summary
 float shrinkage
          Shrinkage parameter.
 
Fields inherited from class org.mymedialite.correlation.CorrelationMatrix
numEntities
 
Fields inherited from class org.mymedialite.datatype.SymmetricMatrix
data, dim
 
Constructor Summary
Pearson(int numEntities)
          Constructor.
 
Method Summary
static float computeCorrelation(IRatings ratings, EntityType entityType, int i, int j, float shrinkage)
          Compute correlations between two entities for given ratings.
 void computeCorrelations(IRatings ratings, EntityType entityType)
          Compute correlations for given ratings.
static CorrelationMatrix create(IRatings ratings, EntityType entityType, float shrinkage)
          Create a Pearson correlation matrix from given data.
 
Methods inherited from class org.mymedialite.correlation.CorrelationMatrix
addEntity, create, getNearestNeighbors, getPositivelyCorrelatedEntities, isSymmetric, readCorrelationMatrix, sumUp, write
 
Methods inherited from class org.mymedialite.datatype.SymmetricMatrix
createMatrix, get, grow, init, numberOfColumns, numberOfRows, set, transpose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shrinkage

public float shrinkage
Shrinkage parameter.

Constructor Detail

Pearson

public Pearson(int numEntities)
Constructor. Create a Pearson correlation matrix.

Parameters:
numEntities - the number of entities
Method Detail

create

public static CorrelationMatrix create(IRatings ratings,
                                       EntityType entityType,
                                       float shrinkage)
Create a Pearson correlation matrix from given data.

Parameters:
ratings - the ratings data
entityType - the entity type, either USER or ITEM
shrinkage - a shrinkage parameter
Returns:
the complete Pearson correlation matrix

computeCorrelation

public static float computeCorrelation(IRatings ratings,
                                       EntityType entityType,
                                       int i,
                                       int j,
                                       float shrinkage)
Compute correlations between two entities for given ratings.

Parameters:
ratings - the rating data
entityType - the entity type, either USER or ITEM
i - the ID of first entity
j - the ID of second entity
shrinkage - the shrinkage parameter

computeCorrelations

public void computeCorrelations(IRatings ratings,
                                EntityType entityType)
Compute correlations for given ratings.

Specified by:
computeCorrelations in class RatingCorrelationMatrix
Parameters:
ratings - the rating data
entityType - the entity type, either USER or ITEM