regularized_svd_method.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_REGULARIZED_SVD_METHOD_HPP
15 #define MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_REGULARIZED_SVD_METHOD_HPP
16 
17 #include <mlpack/prereqs.hpp>
19 
20 namespace mlpack {
21 namespace cf {
22 
28 {
29  public:
36  RegSVDPolicy(const size_t maxIterations = 10) :
37  maxIterations(maxIterations)
38  {
39  /* Nothing to do here */
40  }
41 
56  void Apply(const arma::mat& data,
57  const arma::sp_mat& /* cleanedData */,
58  const size_t rank,
59  arma::mat& w,
60  arma::mat& h,
61  const size_t maxIterations,
62  const double /* minResidue */,
63  const bool /* mit */)
64  {
65  // Do singular value decomposition using the regularized SVD algorithm.
66  svd::RegularizedSVD<> regsvd(maxIterations);
67  regsvd.Apply(data, rank, w, h);
68  }
69 
71  size_t MaxIterations() const { return maxIterations; }
73  size_t& MaxIterations() { return maxIterations; }
74 
75  private:
77  size_t maxIterations;
78 };
79 
80 } // namespace cf
81 } // namespace mlpack
82 
83 #endif
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...
.hpp
Definition: add_to_po.hpp:21
void Apply(const arma::mat &data, const arma::sp_mat &, const size_t rank, arma::mat &w, arma::mat &h, const size_t maxIterations, const double, const bool)
Apply Collaborative Filtering to the provided data set using the regularized SVD. ...
size_t MaxIterations() const
Get the number of iterations.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t & MaxIterations()
Modify the number of iterations.
Implementation of the Regularized SVD policy to act as a wrapper when accessing Regularized SVD from ...
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.