batch_svd_method.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_BATCH_SVD_HPP
14 #define MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_BATCH_SVD_HPP
15 
16 #include <mlpack/prereqs.hpp>
21 
22 namespace mlpack {
23 namespace cf {
24 
30 {
31  public:
46  template<typename MatType>
47  void Apply(const MatType& /* data */,
48  const arma::sp_mat& cleanedData,
49  const size_t rank,
50  arma::mat& w,
51  arma::mat& h,
52  const size_t maxIterations,
53  const double minResidue,
54  const bool mit)
55  {
56  if (mit)
57  {
58  amf::MaxIterationTermination iter(maxIterations);
59 
60  // Do singular value decomposition using the batch SVD algorithm.
62  amf::SVDBatchLearning> svdbatch(iter);
63 
64  svdbatch.Apply(cleanedData, rank, w, h);
65  }
66  else
67  {
68  amf::SimpleResidueTermination srt(minResidue, maxIterations);
69 
70  // Do singular value decomposition using the batch SVD algorithm.
71  amf::SVDBatchFactorizer<> svdbatch(srt);
72 
73  svdbatch.Apply(cleanedData, rank, w, h);
74  }
75  }
76 };
77 
78 } // namespace cf
79 } // namespace mlpack
80 
81 #endif
This class implements AMF (alternating matrix factorization) on the given matrix V.
Definition: amf.hpp:78
This initialization rule for AMF simply fills the W and H matrices with uniform random noise in [0...
Definition: random_init.hpp:25
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
This class implements a simple residue-based termination policy.
This class implements SVD batch learning with momentum.
void Apply(const MatType &, const arma::sp_mat &cleanedData, const size_t rank, arma::mat &w, arma::mat &h, const size_t maxIterations, const double minResidue, const bool mit)
Apply Collaborative Filtering to the provided data set using the batch SVD method.
double Apply(const MatType &V, const size_t r, arma::mat &W, arma::mat &H)
Apply Alternating Matrix Factorization to the provided matrix.
Implementation of the Batch SVD policy to act as a wrapper when accessing Batch SVD from within CFTyp...
This termination policy only terminates when the maximum number of iterations has been reached...