GClasses
|
This factors the sparse matrix of ratings, M, such that M = PQ^T where each row in P gives the principal preferences for the corresponding user, and each row in Q gives the linear combination of those preferences that map to a rating for an item. (Actually, P and Q also contain an extra column added for a bias.) This class is implemented according to the specification on page 631 in Takacs, G., Pilaszy, I., Nemeth, B., and Tikk, D. Scalable collaborative filtering approaches for large recommender systems. The Journal of Machine Learning Research, 10:623–656, 2009. ISSN 1532-4435., except with the addition of learning-rate decay and a different stopping criteria. More...
#include <GRecommender.h>
Public Member Functions | |
GMatrixFactorization (size_t intrinsicDims, GRand &rand) | |
General-purpose constructor. | |
GMatrixFactorization (GDomNode *pNode, GLearnerLoader &ll) | |
Deserialization constructor. | |
virtual | ~GMatrixFactorization () |
Destructor. | |
void | setRegularizer (double d) |
Set the regularization value. | |
virtual void | train (GMatrix &data) |
See the comment for GCollaborativeFilter::train. | |
virtual double | predict (size_t user, size_t item) |
See the comment for GCollaborativeFilter::predict. | |
virtual void | impute (double *pVec, size_t dims) |
See the comment for GCollaborativeFilter::impute. | |
GMatrix * | getP () |
Returns the matrix of user preference vectors. | |
GMatrix * | getQ () |
Returns the matrix of item weight vectors. | |
virtual GDomNode * | serialize (GDom *pDoc) |
See the comment for GCollaborativeFilter::serialize. | |
void | noInputBias () |
Specify to use no bias value with the inputs. | |
Static Public Member Functions | |
static void | test () |
Performs unit tests. Throws if a failure occurs. Returns if successful. | |
Protected Member Functions | |
double | validate (GMatrix &data) |
Returns the sum-squared error for the specified set of ratings. | |
Protected Attributes | |
size_t | m_intrinsicDims |
double | m_regularizer |
GMatrix * | m_pP |
GMatrix * | m_pQ |
bool | m_useInputBias |
This factors the sparse matrix of ratings, M, such that M = PQ^T where each row in P gives the principal preferences for the corresponding user, and each row in Q gives the linear combination of those preferences that map to a rating for an item. (Actually, P and Q also contain an extra column added for a bias.) This class is implemented according to the specification on page 631 in Takacs, G., Pilaszy, I., Nemeth, B., and Tikk, D. Scalable collaborative filtering approaches for large recommender systems. The Journal of Machine Learning Research, 10:623–656, 2009. ISSN 1532-4435., except with the addition of learning-rate decay and a different stopping criteria.
GClasses::GMatrixFactorization::GMatrixFactorization | ( | size_t | intrinsicDims, |
GRand & | rand | ||
) |
General-purpose constructor.
GClasses::GMatrixFactorization::GMatrixFactorization | ( | GDomNode * | pNode, |
GLearnerLoader & | ll | ||
) |
Deserialization constructor.
virtual GClasses::GMatrixFactorization::~GMatrixFactorization | ( | ) | [virtual] |
Destructor.
GMatrix* GClasses::GMatrixFactorization::getP | ( | ) | [inline] |
Returns the matrix of user preference vectors.
GMatrix* GClasses::GMatrixFactorization::getQ | ( | ) | [inline] |
Returns the matrix of item weight vectors.
virtual void GClasses::GMatrixFactorization::impute | ( | double * | pVec, |
size_t | dims | ||
) | [virtual] |
See the comment for GCollaborativeFilter::impute.
Implements GClasses::GCollaborativeFilter.
void GClasses::GMatrixFactorization::noInputBias | ( | ) | [inline] |
Specify to use no bias value with the inputs.
virtual double GClasses::GMatrixFactorization::predict | ( | size_t | user, |
size_t | item | ||
) | [virtual] |
See the comment for GCollaborativeFilter::predict.
Implements GClasses::GCollaborativeFilter.
See the comment for GCollaborativeFilter::serialize.
Implements GClasses::GCollaborativeFilter.
void GClasses::GMatrixFactorization::setRegularizer | ( | double | d | ) | [inline] |
Set the regularization value.
static void GClasses::GMatrixFactorization::test | ( | ) | [static] |
Performs unit tests. Throws if a failure occurs. Returns if successful.
virtual void GClasses::GMatrixFactorization::train | ( | GMatrix & | data | ) | [virtual] |
See the comment for GCollaborativeFilter::train.
Implements GClasses::GCollaborativeFilter.
double GClasses::GMatrixFactorization::validate | ( | GMatrix & | data | ) | [protected] |
Returns the sum-squared error for the specified set of ratings.
size_t GClasses::GMatrixFactorization::m_intrinsicDims [protected] |
GMatrix* GClasses::GMatrixFactorization::m_pP [protected] |
GMatrix* GClasses::GMatrixFactorization::m_pQ [protected] |
double GClasses::GMatrixFactorization::m_regularizer [protected] |
bool GClasses::GMatrixFactorization::m_useInputBias [protected] |