SYNOPSIS

Public Member Functions

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. template<typename MatType > double Apply (const MatType &V, const size_t r, arma::mat &W, arma::mat &H)

Apply Alternating Matrix Factorization to the provided matrix. const InitializationRuleType & InitializeRule () const

Access the initialization rule. InitializationRuleType & InitializeRule ()

Modify the initialization rule. const TerminationPolicyType & TerminationPolicy () const

Access the termination policy. TerminationPolicyType & TerminationPolicy ()

Modify the termination policy. const UpdateRuleType & Update () const

Access the update rule. UpdateRuleType & Update ()

Modify the update rule.

Private Attributes

InitializationRuleType initializationRule

Instantiated initialization Rule. TerminationPolicyType terminationPolicy

Termination policy. UpdateRuleType update

Instantiated update rule.

Detailed Description

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate>class mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >

This class implements AMF (alternating matrix factorization) on the given matrix V.

Alternating matrix factorization decomposes V in the form $ V \approx WH $ where W is called the basis matrix and H is called the encoding matrix. V is taken to be of size n x m and the obtained W is n x r and H is r x m. The size r is called the rank of the factorization.

The implementation requires three template types; the first contains the policy used to determine when the algorithm has converged; the second contains the initialization rule for the W and H matrix; the last contains the update rule to be used during each iteration. This templatization allows the user to try various update rules, initialization rules, and termination policies (including ones not supplied with MLPACK) for factorization. By default, the template parameters to AMF implement non-negative matrix factorization with the multiplicative distance update.

A simple example of how to run AMF (or NMF) is shown below.

extern arma::mat V; // Matrix that we want to perform LMF on.
size_t r = 10; // Rank of decomposition
arma::mat W; // Basis matrix
arma::mat H; // Encoding matrix

AMF<> amf; // Default options: NMF with multiplicative distance update rules.
amf.Apply(V, W, H, r);

Template Parameters:

TerminationPolicy The policy to use for determining when the factorization has converged.

InitializationRule The initialization rule for initializing W and H matrix.

UpdateRule The update rule for calculating W and H matrix at each iteration.

See also:

NMF_MultiplicativeDistanceUpdate

Definition at line 77 of file amf.hpp.

Constructor & Destructor Documentation

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::\fBAMF\fP (const TerminationPolicyType &terminationPolicy = \fCTerminationPolicyType()\fP, const InitializationRuleType &initializeRule = \fCInitializationRuleType()\fP, const UpdateRuleType &update = \fCUpdateRuleType()\fP)

Create the AMF object and (optionally) set the parameters which AMF will run with. The minimum residue refers to the root mean square of the difference between two subsequent iterations of the product W * H. A low residue indicates that subsequent iterations are not producing much change in W and H. Once the residue goes below the specified minimum residue, the algorithm terminates.

Parameters:

initializationRule Optional instantiated InitializationRule object for initializing the W and H matrices.

updateRule Optional instantiated UpdateRule object; this parameter is useful when the update rule for the W and H vector has state that it needs to store (i.e. HUpdate() and WUpdate() are not static functions).

terminationPolicy Optional instantiated TerminationPolicy object.

Member Function Documentation

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> template<typename MatType > double \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::Apply (const MatType &V, const size_tr, arma::mat &W, arma::mat &H)

Apply Alternating Matrix Factorization to the provided matrix.

Parameters:

V Input matrix to be factorized.

W Basis matrix to be output.

H Encoding matrix to output.

r Rank r of the factorization.

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> const InitializationRuleType& \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::InitializeRule () const\fC [inline]\fP

Access the initialization rule.

Definition at line 121 of file amf.hpp.

References mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::initializationRule.

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> InitializationRuleType& \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::InitializeRule ()\fC [inline]\fP

Modify the initialization rule.

Definition at line 124 of file amf.hpp.

References mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::initializationRule.

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> const TerminationPolicyType& \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::TerminationPolicy () const\fC [inline]\fP

Access the termination policy.

Definition at line 115 of file amf.hpp.

References mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::terminationPolicy.

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> TerminationPolicyType& \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::TerminationPolicy ()\fC [inline]\fP

Modify the termination policy.

Definition at line 118 of file amf.hpp.

References mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::terminationPolicy.

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> const UpdateRuleType& \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::Update () const\fC [inline]\fP

Access the update rule.

Definition at line 127 of file amf.hpp.

References mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::update.

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> UpdateRuleType& \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::Update ()\fC [inline]\fP

Modify the update rule.

Definition at line 129 of file amf.hpp.

References mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::update.

Member Data Documentation

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> InitializationRuleType \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::initializationRule\fC [private]\fP

Instantiated initialization Rule.

Definition at line 135 of file amf.hpp.

Referenced by mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::InitializeRule().

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> TerminationPolicyType \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::terminationPolicy\fC [private]\fP

Termination policy.

Definition at line 133 of file amf.hpp.

Referenced by mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::TerminationPolicy().

template<typename TerminationPolicyType = SimpleResidueTermination, typename InitializationRuleType = RandomInitialization, typename UpdateRuleType = NMFMultiplicativeDistanceUpdate> UpdateRuleType \fBmlpack::amf::AMF\fP< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::update\fC [private]\fP

Instantiated update rule.

Definition at line 137 of file amf.hpp.

Referenced by mlpack::amf::AMF< TerminationPolicyType, InitializationRuleType, UpdateRuleType >::Update().

Author

Generated automatically by Doxygen for MLPACK from the source code.