nmf_method.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_NMF_METHOD_HPP
14 #define MLPACK_METHODS_CF_DECOMPOSITION_POLICIES_NMF_METHOD_HPP
15 
16 #include <mlpack/prereqs.hpp>
21 
22 namespace mlpack {
23 namespace cf {
24 
29 class NMFPolicy
30 {
31  public:
45  template<typename MatType>
46  void Apply(const MatType& /* data */,
47  const arma::sp_mat& cleanedData,
48  const size_t rank,
49  arma::mat& w,
50  arma::mat& h,
51  const size_t maxIterations,
52  const double minResidue,
53  const bool mit)
54  {
55  if (mit)
56  {
57  amf::MaxIterationTermination iter(maxIterations);
58 
59  // Do singular value decomposition using the NMF algorithm.
61  amf::NMFALSUpdate> nmf(iter);
62  nmf.Apply(cleanedData, rank, w, h);
63  }
64  else
65  {
66  amf::SimpleResidueTermination srt(minResidue, maxIterations);
67 
68  // Do singular value decomposition using the NMF algorithm.
69  amf::NMFALSFactorizer nmf(srt);
70  nmf.Apply(cleanedData, rank, w, h);
71  }
72  }
73 };
74 
75 } // namespace cf
76 } // namespace mlpack
77 
78 #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.
Implementation of the NMF policy to act as a wrapper when accessing NMF from within CFType...
Definition: nmf_method.hpp:29
This class implements a simple residue-based termination policy.
This class implements a method titled &#39;Alternating Least Squares&#39; described in the following paper: ...
Definition: nmf_als.hpp:41
double Apply(const MatType &V, const size_t r, arma::mat &W, arma::mat &H)
Apply Alternating Matrix Factorization to the provided matrix.
This termination policy only terminates when the maximum number of iterations has been reached...
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 dataset using NMF method.
Definition: nmf_method.hpp:46