NMFPolicy Class Reference

Implementation of the NMF policy to act as a wrapper when accessing NMF from within CFType. More...

Public Member Functions

template
<
typename
MatType
>
void Apply (const MatType &, const arma::sp_mat &cleanedData, const size_t rank, const size_t maxIterations, const double minResidue, const bool mit)
 Apply Collaborative Filtering to the provided dataset using NMF method. More...

 
template
<
typename
NeighborSearchPolicy
>
void GetNeighborhood (const arma::Col< size_t > &users, const size_t numUsersForSimilarity, arma::Mat< size_t > &neighborhood, arma::mat &similarities) const
 Get the neighborhood and corresponding similarities for a set of users. More...

 
double GetRating (const size_t user, const size_t item) const
 Return predicted rating given user ID and item ID. More...

 
void GetRatingOfUser (const size_t user, arma::vec &rating) const
 Get predicted ratings for a user. More...

 
const arma::mat & H () const
 Get the User Matrix. More...

 
template
<
typename
Archive
>
void serialize (Archive &ar, const uint32_t)
 Serialization. More...

 
const arma::mat & W () const
 Get the Item Matrix. More...

 

Detailed Description

Implementation of the NMF policy to act as a wrapper when accessing NMF from within CFType.

An example of how to use NMFPolicy in CF is shown below:

extern arma::mat data; // data is a (user, item, rating) table.
// Users for whom recommendations are generated.
extern arma::Col<size_t> users;
arma::Mat<size_t> recommendations; // Resulting recommendations.
CFType<NMFPolicy> cf(data);
// Generate 10 recommendations for all users.
cf.GetRecommendations(10, recommendations);

Definition at line 43 of file nmf_method.hpp.

Member Function Documentation

◆ Apply()

void Apply ( const MatType &  ,
const arma::sp_mat &  cleanedData,
const size_t  rank,
const size_t  maxIterations,
const double  minResidue,
const bool  mit 
)
inline

Apply Collaborative Filtering to the provided dataset using NMF method.

Parameters
*(data) Data matrix: dense matrix (coordinate lists) or sparse matrix (cleaned).
cleanedDataitem user table in form of sparse matrix.
rankRank parameter for matrix factorization.
maxIterationsMaximum number of iterations.
minResidueResidue required to terminate.
mitWhether to terminate only when maxIterations is reached.

Definition at line 58 of file nmf_method.hpp.

References AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::Apply().

◆ GetNeighborhood()

void GetNeighborhood ( const arma::Col< size_t > &  users,
const size_t  numUsersForSimilarity,
arma::Mat< size_t > &  neighborhood,
arma::mat &  similarities 
) const
inline

Get the neighborhood and corresponding similarities for a set of users.

Template Parameters
NeighborSearchPolicyThe policy to perform neighbor search.
Parameters
usersUsers whose neighborhood is to be computed.
numUsersForSimilarityThe number of neighbors returned for each user.
neighborhoodNeighbors represented by user IDs.
similaritiesSimilarity between each user and each of its neighbors.

Definition at line 120 of file nmf_method.hpp.

◆ GetRating()

double GetRating ( const size_t  user,
const size_t  item 
) const
inline

Return predicted rating given user ID and item ID.

Parameters
userUser ID.
itemItem ID.

Definition at line 90 of file nmf_method.hpp.

◆ GetRatingOfUser()

void GetRatingOfUser ( const size_t  user,
arma::vec &  rating 
) const
inline

Get predicted ratings for a user.

Parameters
userUser ID.
ratingResulting rating vector.

Definition at line 102 of file nmf_method.hpp.

◆ H()

const arma::mat& H ( ) const
inline

Get the User Matrix.

Definition at line 149 of file nmf_method.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)
inline

Serialization.

Definition at line 155 of file nmf_method.hpp.

◆ W()

const arma::mat& W ( ) const
inline

Get the Item Matrix.

Definition at line 147 of file nmf_method.hpp.


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/methods/cf/decomposition_policies/nmf_method.hpp