MLPACK
1.0.8
|
This class implements Collaborative Filtering (CF). More...
Public Member Functions | |
CF (const size_t numRecs, const size_t numUsersForSimilarity, arma::mat &data) | |
Create a CF object and (optionally) set the parameters with which collaborative filtering will be run. More... | |
CF (const size_t numRecs, arma::mat &data) | |
Create a CF object and (optionally) set the parameters which CF will be run with. More... | |
CF (arma::mat &data) | |
Create a CF object and (optionally) set the parameters which CF will be run with. More... | |
const arma::sp_mat & | CleanedData () const |
Get the cleaned data matrix. More... | |
const arma::mat & | Data () const |
Get the data matrix. More... | |
void | GetRecommendations (arma::Mat< size_t > &recommendations) |
Generates default number of recommendations for all users. More... | |
void | GetRecommendations (arma::Mat< size_t > &recommendations, arma::Col< size_t > &users) |
Generates default number of recommendations for specified users. More... | |
void | GetRecommendations (arma::Mat< size_t > &recommendations, arma::Col< size_t > &users, size_t num) |
Generates a fixed number of recommendations for specified users. More... | |
void | GetRecommendations (arma::Mat< size_t > &recommendations, arma::Col< size_t > &users, size_t num, size_t neighbours) |
Generates a fixed number of recommendations for specified users. More... | |
const arma::mat & | H () const |
Get the Item Matrix. More... | |
void | NumRecs (size_t recs) |
Sets number of Recommendations. More... | |
size_t | NumRecs () |
Gets numRecs. More... | |
void | NumUsersForSimilarity (size_t num) |
Sets number of user for calculating similarity. More... | |
size_t | NumUsersForSimilarity () |
Gets number of users for calculating similarity/. More... | |
const arma::mat & | Rating () const |
Get the Rating Matrix. More... | |
const arma::mat & | W () const |
Get the User Matrix. More... | |
Private Member Functions | |
void | CleanData () |
Converts the User, Item, Value Matrix to User-Item Table. More... | |
void | InsertNeighbor (const size_t queryIndex, const size_t pos, const size_t neighbor, const double value, arma::Mat< size_t > &recommendations, arma::mat &values) const |
Helper function to insert a point into the recommendation matrices. More... | |
Private Attributes | |
arma::sp_mat | cleanedData |
Cleaned data matrix. More... | |
arma::mat | data |
Initial data matrix. More... | |
arma::mat | h |
Item matrix. More... | |
size_t | numRecs |
Number of recommendations. More... | |
size_t | numUsersForSimilarity |
Number of users for similarity. More... | |
arma::mat | rating |
Rating matrix. More... | |
arma::mat | w |
User matrix. More... | |
This class implements Collaborative Filtering (CF).
This implementation presently supports Alternating Least Squares (ALS) for collaborative filtering.
A simple example of how to run Collaborative Filtering is shown below.
The data matrix is a (user, item, rating) table. Each column in the matrix should have three rows. The first represents the user; the second represents the item; and the third represents the rating. The user and item, while they are in a matrix that holds doubles, should hold integer (or size_t) values.
mlpack::cf::CF::CF | ( | const size_t | numRecs, |
const size_t | numUsersForSimilarity, | ||
arma::mat & | data | ||
) |
Create a CF object and (optionally) set the parameters with which collaborative filtering will be run.
data | Initial (user,item,rating) matrix. |
numRecs | Desired number of recommendations for each user. |
numUsersForSimilarity | Size of the neighborhood. |
mlpack::cf::CF::CF | ( | const size_t | numRecs, |
arma::mat & | data | ||
) |
mlpack::cf::CF::CF | ( | arma::mat & | data | ) |
|
private |
Converts the User, Item, Value Matrix to User-Item Table.
|
inline |
|
inline |
void mlpack::cf::CF::GetRecommendations | ( | arma::Mat< size_t > & | recommendations | ) |
Generates default number of recommendations for all users.
recommendations | Matrix to save recommendations into. |
void mlpack::cf::CF::GetRecommendations | ( | arma::Mat< size_t > & | recommendations, |
arma::Col< size_t > & | users | ||
) |
Generates default number of recommendations for specified users.
recommendations | Matrix to save recommendations |
users | Users for which recommendations are to be generated |
void mlpack::cf::CF::GetRecommendations | ( | arma::Mat< size_t > & | recommendations, |
arma::Col< size_t > & | users, | ||
size_t | num | ||
) |
Generates a fixed number of recommendations for specified users.
recommendations | Matrix to save recommendations |
users | Users for which recommendations are to be generated |
num | Number of Recommendations |
void mlpack::cf::CF::GetRecommendations | ( | arma::Mat< size_t > & | recommendations, |
arma::Col< size_t > & | users, | ||
size_t | num, | ||
size_t | neighbours | ||
) |
Generates a fixed number of recommendations for specified users.
recommendations | Matrix to save recommendations |
users | Users for which recommendations are to be generated |
num | Number of Recommendations |
neighbours | Number of user to be considered while calculating the neighbourhood |
|
inline |
|
private |
Helper function to insert a point into the recommendation matrices.
queryIndex | Index of point whose recommendations we are inserting into. |
pos | Position in list to insert into. |
neighbor | Index of item being inserted as a recommendation. |
value | Value of recommendation. |
|
inline |
Sets number of Recommendations.
Definition at line 100 of file cf.hpp.
References mlpack::Log::Warn.
|
inline |
|
inline |
Sets number of user for calculating similarity.
Definition at line 118 of file cf.hpp.
References mlpack::Log::Warn.
|
inline |
Gets number of users for calculating similarity/.
Definition at line 130 of file cf.hpp.
References numUsersForSimilarity.
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
Number of users for similarity.
Definition at line 189 of file cf.hpp.
Referenced by NumUsersForSimilarity().
|
private |
|
private |