mlpack
Functions
cf_main.cpp File Reference
#include <mlpack/prereqs.hpp>
#include <mlpack/core/util/io.hpp>
#include <mlpack/core/util/mlpack_main.hpp>
#include <mlpack/core/math/random.hpp>
#include "cf.hpp"
#include "cf_model.hpp"
#include <mlpack/methods/cf/decomposition_policies/batch_svd_method.hpp>
#include <mlpack/methods/cf/decomposition_policies/randomized_svd_method.hpp>
#include <mlpack/methods/cf/decomposition_policies/regularized_svd_method.hpp>
#include <mlpack/methods/cf/decomposition_policies/svd_complete_method.hpp>
#include <mlpack/methods/cf/decomposition_policies/svd_incomplete_method.hpp>
#include <mlpack/methods/cf/decomposition_policies/bias_svd_method.hpp>
#include <mlpack/methods/cf/decomposition_policies/svdplusplus_method.hpp>
#include <mlpack/methods/cf/interpolation_policies/average_interpolation.hpp>
#include <mlpack/methods/cf/interpolation_policies/regression_interpolation.hpp>
#include <mlpack/methods/cf/interpolation_policies/similarity_interpolation.hpp>
#include <mlpack/methods/cf/neighbor_search_policies/cosine_search.hpp>
#include <mlpack/methods/cf/neighbor_search_policies/lmetric_search.hpp>
#include <mlpack/methods/cf/neighbor_search_policies/pearson_search.hpp>
Include dependency graph for cf_main.cpp:

Functions

 BINDING_NAME ("Collaborative Filtering")
 
 BINDING_SHORT_DESC ("An implementation of several collaborative filtering (CF) techniques for " "recommender systems. This can be used to train a new CF model, or use an" " existing CF model to compute recommendations.")
 
 BINDING_LONG_DESC ("This program performs collaborative " "filtering (CF) on the given dataset. Given a list of user, item and " "preferences (the "+PRINT_PARAM_STRING("training")+" parameter), " "the program will perform a matrix decomposition and then can perform a " "series of actions related to collaborative filtering. Alternately, the " "program can load an existing saved CF model with the "+PRINT_PARAM_STRING("input_model")+" parameter and then use that model " "to provide recommendations or predict values." "\" "The input matrix should be a 3-dimensional matrix of ratings, where the " "first dimension is the user, the second dimension is the item, and the " "third dimension is that user's rating of that item. Both the users and " "items should be numeric indices, not names. The indices are assumed to " "start from 0." "\" "A set of query users for which recommendations can be generated may be " "specified with the "+PRINT_PARAM_STRING("query")+" parameter; " "alternately, recommendations may be generated for every user in the " "dataset by specifying the "+PRINT_PARAM_STRING("all_user_recommendations")+" parameter. In " "addition, the number of recommendations per user to generate can be " "specified with the "+PRINT_PARAM_STRING("recommendations")+" " "parameter, and the number of similar users (the size of the neighborhood) " "to be considered when generating recommendations can be specified with " "the "+PRINT_PARAM_STRING("neighborhood")+" parameter." "\" "For performing the matrix decomposition, the following optimization " "algorithms can be specified via the "+PRINT_PARAM_STRING("algorithm")+" parameter: " "\ " - 'RegSVD' -- Regularized SVD using a SGD optimizer\" " - 'NMF' -- Non-negative matrix factorization with alternating least " "squares update rules\" " - 'BatchSVD' -- SVD batch learning\" " - 'SVDIncompleteIncremental' -- SVD incomplete incremental learning\" " - 'SVDCompleteIncremental' -- SVD complete incremental learning\" " - 'BiasSVD' -- Bias SVD using a SGD optimizer\" " - 'SVDPP' -- SVD++using a SGD optimizer\" "\\" "The following neighbor search algorithms can be specified via"+" the "+PRINT_PARAM_STRING("neighbor_search")+" parameter:" "\" " - 'cosine' -- Cosine Search Algorithm\" " - 'euclidean' -- Euclidean Search Algorithm\" " - 'pearson' -- Pearson Search Algorithm\" "\\" "The following weight interpolation algorithms can be specified via"+" the "+PRINT_PARAM_STRING("interpolation")+" parameter:" "\" " - 'average' -- Average Interpolation Algorithm\" " - 'regression' -- Regression Interpolation Algorithm\" " - 'similarity' -- Similarity Interpolation Algorithm\" "\\" "The following ranking normalization algorithms can be specified via"+" the "+PRINT_PARAM_STRING("normalization")+" parameter:" "\" " - 'none' -- No Normalization\" " - 'item_mean' -- Item Mean Normalization\" " - 'overall_mean' -- Overall Mean Normalization\" " - 'user_mean' -- User Mean Normalization\" " - 'z_score' -- Z-Score Normalization\" "\" "A trained model may be saved to with the "+PRINT_PARAM_STRING("output_model")+" output parameter.")
 
 BINDING_EXAMPLE ("To train a CF model on a dataset "+PRINT_DATASET("training_set")+" " "using NMF for decomposition and saving the trained model to "+PRINT_MODEL("model")+", one could call: " "\"+PRINT_CALL("cf", "training", "training_set", "algorithm", "NMF", "output_model", "model")+"\" "Then, to use this model to generate recommendations for the list of users " "in the query set "+PRINT_DATASET("users")+", storing 5 " "recommendations in "+PRINT_DATASET("recommendations")+", one could " "call " "\"+PRINT_CALL("cf", "input_model", "model", "query", "users", "recommendations", 5, "output", "recommendations"))
 
 BINDING_SEE_ALSO ("Collaborative filtering tutorial", "@doxygen/cftutorial.html")
 
 BINDING_SEE_ALSO ("Alternating Matrix Factorization tutorial", "@doxygen/amftutorial.html")
 
 BINDING_SEE_ALSO ("Collaborative Filtering on Wikipedia", "https://en.wikipedia.org/wiki/Collaborative_filtering")
 
 BINDING_SEE_ALSO ("Matrix factorization on Wikipedia", "https://en.wikipedia.org/wiki/Matrix_factorization_" "(recommender_systems)")
 
 BINDING_SEE_ALSO ("Matrix factorization techniques for recommender systems" " (pdf)", "http://citeseerx.ist.psu.edu/viewdoc/download?doi=" "10.1.1.441.3234&rep=rep1&type=pdf")
 
 BINDING_SEE_ALSO ("mlpack::cf::CFType class documentation", "@doxygen/classmlpack_1_1cf_1_1CFType.html")
 
 PARAM_MATRIX_IN ("training", "Input dataset to perform CF on.", "t")
 
 PARAM_STRING_IN ("algorithm", "Algorithm used for matrix factorization.", "a", "NMF")
 
 PARAM_STRING_IN ("normalization", "Normalization performed on the ratings.", "z", "none")
 
 PARAM_INT_IN ("neighborhood", "Size of the neighborhood of similar users to " "consider for each query user.", "n", 5)
 
 PARAM_INT_IN ("rank", "Rank of decomposed matrices (if 0, a heuristic is used to" " estimate the rank).", "R", 0)
 
 PARAM_MATRIX_IN ("test", "Test set to calculate RMSE on.", "T")
 
 PARAM_INT_IN ("max_iterations", "Maximum number of iterations. If set to zero, " "there is no limit on the number of iterations.", "N", 1000)
 
 PARAM_FLAG ("iteration_only_termination", "Terminate only when the maximum " "number of iterations is reached.", "I")
 
 PARAM_DOUBLE_IN ("min_residue", "Residue required to terminate the factorization" " (lower values generally mean better fits).", "r", 1e-5)
 
 PARAM_MODEL_IN (CFModel, "input_model", "Trained CF model to load.", "m")
 
 PARAM_MODEL_OUT (CFModel, "output_model", "Output for trained CF model.", "M")
 
 PARAM_UMATRIX_IN ("query", "List of query users for which recommendations should" " be generated.", "q")
 
 PARAM_FLAG ("all_user_recommendations", "Generate recommendations for all " "users.", "A")
 
 PARAM_UMATRIX_OUT ("output", "Matrix that will store output recommendations.", "o")
 
 PARAM_INT_IN ("recommendations", "Number of recommendations to generate for each" " query user.", "c", 5)
 
 PARAM_INT_IN ("seed", "Set the random seed (0 uses std::time(NULL)).", "s", 0)
 
 PARAM_STRING_IN ("interpolation", "Algorithm used for weight interpolation.", "i", "average")
 
 PARAM_STRING_IN ("neighbor_search", "Algorithm used for neighbor search.", "S", "euclidean")
 

Detailed Description

Author
Mudit Raj Gupta

Main executable to run CF.

mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license. You should have received a copy of the 3-clause BSD license along with mlpack. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information.