14 #ifndef MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_REGULARIZED_SVD_METHOD_HPP    15 #define MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_REGULARIZED_SVD_METHOD_HPP    51       maxIterations(maxIterations)
    68   void Apply(
const arma::mat& data,
    71              const size_t maxIterations,
    77     regsvd.
Apply(data, rank, w, h);
    86   double GetRating(
const size_t user, 
const size_t item)
 const    88     double rating = arma::as_scalar(w.row(item) * h.col(user));
   100     rating = w * h.col(user);
   115   template<
typename NeighborSearchPolicy>
   117                        const size_t numUsersForSimilarity,
   118                        arma::Mat<size_t>& neighborhood,
   119                        arma::mat& similarities)
 const   128     arma::mat l = arma::chol(w.t() * w);
   129     arma::mat stretchedH = l * h; 
   132     arma::mat query(stretchedH.n_rows, users.n_elem);
   134     for (
size_t i = 0; i < users.n_elem; ++i)
   135       query.col(i) = stretchedH.col(users(i));
   137     NeighborSearchPolicy neighborSearch(stretchedH);
   138     neighborSearch.Search(
   139         query, numUsersForSimilarity, neighborhood, similarities);
   143   const arma::mat& 
W()
 const { 
return w; }
   145   const arma::mat& 
H()
 const { 
return h; }
   155   template<
typename Archive>
   164   size_t maxIterations;
 RegSVDPolicy(const size_t maxIterations=10)
Use regularized SVD method to perform collaborative filtering. 
 
Regularized SVD is a matrix factorization technique that seeks to reduce the error on the training se...
 
Linear algebra utility functions, generally performed on matrices or vectors. 
 
const arma::mat & H() const
Get the User Matrix. 
 
size_t MaxIterations() const
Get the number of iterations. 
 
The core includes that mlpack expects; standard C++ includes and Armadillo. 
 
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. 
 
double GetRating(const size_t user, const size_t item) const
Return predicted rating given user ID and item ID. 
 
void serialize(Archive &ar, const uint32_t)
Serialization. 
 
size_t & MaxIterations()
Modify the number of iterations. 
 
Implementation of the Regularized SVD policy to act as a wrapper when accessing Regularized SVD from ...
 
const arma::mat & W() const
Get the Item Matrix. 
 
void Apply(const arma::mat &data, const size_t rank, arma::mat &u, arma::mat &v)
Obtains the user and item matrices using the provided data and rank. 
 
void Apply(const arma::mat &data, const arma::sp_mat &, const size_t rank, const size_t maxIterations, const double, const bool)
Apply Collaborative Filtering to the provided data set using the regularized SVD. ...
 
void GetRatingOfUser(const size_t user, arma::vec &rating) const
Get predicted ratings for a user.