mlpack
Public Member Functions | List of all members
mlpack::svd::RandomizedSVD Class Reference

Randomized SVD is a matrix factorization that is based on randomized matrix approximation techniques, developed in in "Finding structure with randomness: Probabilistic algorithms for constructing approximate matrix decompositions". More...

#include <randomized_svd.hpp>

Public Member Functions

 RandomizedSVD (const arma::mat &data, arma::mat &u, arma::vec &s, arma::mat &v, const size_t iteratedPower=0, const size_t maxIterations=2, const size_t rank=0, const double eps=1e-7)
 Create object for the randomized SVD method. More...
 
 RandomizedSVD (const size_t iteratedPower=0, const size_t maxIterations=2, const double eps=1e-7)
 Create object for the randomized SVD method. More...
 
void Apply (const arma::sp_mat &data, arma::mat &u, arma::vec &s, arma::mat &v, const size_t rank)
 Center the data to apply Principal Component Analysis on given sparse matrix dataset using randomized SVD. More...
 
void Apply (const arma::mat &data, arma::mat &u, arma::vec &s, arma::mat &v, const size_t rank)
 Center the data to apply Principal Component Analysis on given matrix dataset using randomized SVD. More...
 
template<typename MatType >
void Apply (const MatType &data, arma::mat &u, arma::vec &s, arma::mat &v, const size_t rank, MatType rowMean)
 Apply Principal Component Analysis to the provided matrix data set using the randomized SVD. More...
 
size_t IteratedPower () const
 Get the size of the normalized power iterations.
 
size_t & IteratedPower ()
 Modify the size of the normalized power iterations.
 
size_t MaxIterations () const
 Get the number of iterations for the power method.
 
size_t & MaxIterations ()
 Modify the number of iterations for the power method.
 
double Epsilon () const
 Get the value used for decomposition stability.
 
double & Epsilon ()
 Modify the value used for decomposition stability.
 

Detailed Description

Randomized SVD is a matrix factorization that is based on randomized matrix approximation techniques, developed in in "Finding structure with randomness: Probabilistic algorithms for constructing approximate matrix decompositions".

For more information, see the following.

@article{Halko2011,
author = {Halko, N. and Martinsson, P. G. and Tropp, J. A.},
title = {Finding Structure with Randomness: Probabilistic Algorithms for
Constructing Approximate Matrix Decompositions},
journal = {SIAM Rev.},
volume = {53},
year = {2011},
}
@article{Szlam2014,
author = {Arthur Szlam Yuval Kluger and Mark Tygert},
title = {An implementation of a randomized algorithm for principal
component analysis},
journal = {CoRR},
volume = {abs/1412.3510},
year = {2014},
}

An example of how to use the interface is shown below:

arma::mat data; // Rating data in the form of coordinate list.
const size_t rank = 20; // Rank used for the decomposition.
// Make a RandomizedSVD object.
arma::mat u, s, v;
// Use the Apply() method to get a factorization.
rSVD.Apply(data, u, s, v, rank);

Constructor & Destructor Documentation

◆ RandomizedSVD() [1/2]

mlpack::svd::RandomizedSVD::RandomizedSVD ( const arma::mat &  data,
arma::mat &  u,
arma::vec &  s,
arma::mat &  v,
const size_t  iteratedPower = 0,
const size_t  maxIterations = 2,
const size_t  rank = 0,
const double  eps = 1e-7 
)

Create object for the randomized SVD method.

Parameters
dataData matrix.
uFirst unitary matrix.
vSecond unitary matrix.
sDiagonal "Sigma" matrix of singular values.
iteratedPowerSize of the normalized power iterations (Default: rank + 2).
maxIterationsNumber of iterations for the power method (Default: 2).
rankRank of the approximation (Default: number of rows.)
epsThe eps coefficient to avoid division by zero (numerical stability).

◆ RandomizedSVD() [2/2]

mlpack::svd::RandomizedSVD::RandomizedSVD ( const size_t  iteratedPower = 0,
const size_t  maxIterations = 2,
const double  eps = 1e-7 
)

Create object for the randomized SVD method.

Parameters
iteratedPowerSize of the normalized power iterations (Default: rank + 2).
maxIterationsNumber of iterations for the power method (Default: 2).
epsThe eps coefficient to avoid division by zero (numerical stability).

Member Function Documentation

◆ Apply() [1/3]

void mlpack::svd::RandomizedSVD::Apply ( const arma::sp_mat &  data,
arma::mat &  u,
arma::vec &  s,
arma::mat &  v,
const size_t  rank 
)

Center the data to apply Principal Component Analysis on given sparse matrix dataset using randomized SVD.

Parameters
dataSparse data matrix.
uFirst unitary matrix.
vSecond unitary matrix.
sDiagonal "Sigma" matrix of singular values.
rankRank of the approximation.

◆ Apply() [2/3]

void mlpack::svd::RandomizedSVD::Apply ( const arma::mat &  data,
arma::mat &  u,
arma::vec &  s,
arma::mat &  v,
const size_t  rank 
)

Center the data to apply Principal Component Analysis on given matrix dataset using randomized SVD.

Parameters
dataData matrix.
uFirst unitary matrix.
vSecond unitary matrix.
sDiagonal "Sigma" matrix of singular values.
rankRank of the approximation.

◆ Apply() [3/3]

template<typename MatType >
void mlpack::svd::RandomizedSVD::Apply ( const MatType &  data,
arma::mat &  u,
arma::vec &  s,
arma::mat &  v,
const size_t  rank,
MatType  rowMean 
)
inline

Apply Principal Component Analysis to the provided matrix data set using the randomized SVD.

Parameters
dataData matrix.
uFirst unitary matrix.
vSecond unitary matrix.
sDiagonal "Sigma" matrix of singular values.
rankRank of the approximation.
rowMeanCentered mean value matrix.

The documentation for this class was generated from the following files: