mlpack  3.4.2
amf.hpp
Go to the documentation of this file.
1 
18 #ifndef MLPACK_METHODS_AMF_AMF_HPP
19 #define MLPACK_METHODS_AMF_AMF_HPP
20 
21 #include <mlpack/prereqs.hpp>
22 
28 
31 
34 
35 namespace mlpack {
36 namespace amf {
37 
75 template<typename TerminationPolicyType = SimpleResidueTermination,
76  typename InitializationRuleType = RandomAcolInitialization<>,
77  typename UpdateRuleType = NMFMultiplicativeDistanceUpdate>
78 class AMF
79 {
80  public:
97  AMF(const TerminationPolicyType& terminationPolicy = TerminationPolicyType(),
98  const InitializationRuleType& initializeRule = InitializationRuleType(),
99  const UpdateRuleType& update = UpdateRuleType());
100 
109  template<typename MatType>
110  double Apply(const MatType& V,
111  const size_t r,
112  arma::mat& W,
113  arma::mat& H);
114 
116  const TerminationPolicyType& TerminationPolicy() const
117  { return terminationPolicy; }
119  TerminationPolicyType& TerminationPolicy() { return terminationPolicy; }
120 
122  const InitializationRuleType& InitializeRule() const
123  { return initializationRule; }
125  InitializationRuleType& InitializeRule() { return initializationRule; }
126 
128  const UpdateRuleType& Update() const { return update; }
130  UpdateRuleType& Update() { return update; }
131 
132  private:
134  TerminationPolicyType terminationPolicy;
136  InitializationRuleType initializationRule;
138  UpdateRuleType update;
139 }; // class AMF
140 
144 
146 
154 template<typename MatType = arma::mat>
159 
168 template<class MatType = arma::mat>
181 template<class MatType = arma::mat>
186 } // namespace amf
187 } // namespace mlpack
188 
189 // Include implementation.
190 #include "amf_impl.hpp"
191 
192 #endif // MLPACK_METHODS_AMF_AMF_HPP
This class implements AMF (alternating matrix factorization) on the given matrix V.
Definition: amf.hpp:79
UpdateRuleType & Update()
Modify the update rule.
Definition: amf.hpp:130
double Apply(const MatType &V, const size_t r, arma::mat &W, arma::mat &H)
Apply Alternating Matrix Factorization to the provided matrix.
AMF(const TerminationPolicyType &terminationPolicy=TerminationPolicyType(), const InitializationRuleType &initializeRule=InitializationRuleType(), const UpdateRuleType &update=UpdateRuleType())
Create the AMF object and (optionally) set the parameters which AMF will run with.
InitializationRuleType & InitializeRule()
Modify the initialization rule.
Definition: amf.hpp:125
const UpdateRuleType & Update() const
Access the update rule.
Definition: amf.hpp:128
const TerminationPolicyType & TerminationPolicy() const
Access the termination policy.
Definition: amf.hpp:116
TerminationPolicyType & TerminationPolicy()
Modify the termination policy.
Definition: amf.hpp:119
const InitializationRuleType & InitializeRule() const
Access the initialization rule.
Definition: amf.hpp:122
This class implements a method titled 'Alternating Least Squares' described in the following paper:
Definition: nmf_als.hpp:42
The multiplicative distance update rules for matrices W and H.
This class initializes the W matrix of the AMF algorithm by averaging p randomly chosen columns of V.
This class implements SVD batch learning with momentum.
This class computes SVD using complete incremental batch learning, as described in the following pape...
This class computes SVD using incomplete incremental batch learning, as described in the following pa...
This class implements a simple residue-based termination policy.
amf::AMF< amf::SimpleResidueTermination, amf::RandomAcolInitialization<>, amf::NMFALSUpdate > NMFALSFactorizer
Definition: amf.hpp:143
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.