mlpack
3.1.1
src
mlpack
methods
pca
decomposition_policies
quic_svd_method.hpp
Go to the documentation of this file.
1
14
#ifndef MLPACK_METHODS_PCA_DECOMPOSITION_POLICIES_QUIC_SVD_METHOD_HPP
15
#define MLPACK_METHODS_PCA_DECOMPOSITION_POLICIES_QUIC_SVD_METHOD_HPP
16
17
#include <
mlpack/prereqs.hpp
>
18
#include <
mlpack/methods/quic_svd/quic_svd.hpp
>
19
20
namespace
mlpack
{
21
namespace
pca {
22
26
class
QUICSVDPolicy
27
{
28
public
:
35
QUICSVDPolicy
(
const
double
epsilon = 0.03,
const
double
delta = 0.1) :
36
epsilon(epsilon),
37
delta(delta)
38
{
39
/* Nothing to do here */
40
}
41
53
void
Apply
(
const
arma::mat& data,
54
const
arma::mat& centeredData,
55
arma::mat& transformedData,
56
arma::vec& eigVal,
57
arma::mat& eigvec,
58
const
size_t
/* rank */
)
59
{
60
// This matrix will store the right singular values; we do not need them.
61
arma::mat v, sigma;
62
63
// Do singular value decomposition using the QUIC-SVD algorithm.
64
svd::QUIC_SVD
quicsvd(centeredData, eigvec, v, sigma, epsilon, delta);
65
66
// Now we must square the singular values to get the eigenvalues.
67
// In addition we must divide by the number of points, because the
68
// covariance matrix is X * X' / (N - 1).
69
eigVal = arma::pow(arma::diagvec(sigma), 2) / (data.n_cols - 1);
70
71
// Project the samples to the principals.
72
transformedData = arma::trans(eigvec) * centeredData;
73
}
74
76
double
Epsilon
()
const
{
return
epsilon; }
78
double
&
Epsilon
() {
return
epsilon; }
79
81
double
Delta
()
const
{
return
delta; }
83
double
&
Delta
() {
return
delta; }
84
85
private
:
87
double
epsilon;
88
90
double
delta;
91
};
92
93
}
// namespace pca
94
}
// namespace mlpack
95
96
#endif
quic_svd.hpp
prereqs.hpp
mlpack::pca::QUICSVDPolicy::Delta
double Delta() const
Get the cumulative probability for Monte Carlo error lower bound.
Definition:
quic_svd_method.hpp:81
mlpack::pca::QUICSVDPolicy
Implementation of the QUIC-SVD policy.
Definition:
quic_svd_method.hpp:26
mlpack
@serialization.hpp
Definition:
add_to_po.hpp:21
mlpack::pca::QUICSVDPolicy::QUICSVDPolicy
QUICSVDPolicy(const double epsilon=0.03, const double delta=0.1)
Use QUIC-SVD method to perform the principal components analysis (PCA).
Definition:
quic_svd_method.hpp:35
mlpack::svd::QUIC_SVD
QUIC-SVD is a matrix factorization technique, which operates in a subspace such that A's approximatio...
Definition:
quic_svd.hpp:53
mlpack::pca::QUICSVDPolicy::Delta
double & Delta()
Modify the cumulative probability for Monte Carlo error lower bound.
Definition:
quic_svd_method.hpp:83
mlpack::pca::QUICSVDPolicy::Apply
void Apply(const arma::mat &data, const arma::mat ¢eredData, arma::mat &transformedData, arma::vec &eigVal, arma::mat &eigvec, const size_t)
Apply Principal Component Analysis to the provided data set using the QUIC-SVD method.
Definition:
quic_svd_method.hpp:53
mlpack::pca::QUICSVDPolicy::Epsilon
double Epsilon() const
Get the error tolerance fraction for calculated subspace.
Definition:
quic_svd_method.hpp:76
mlpack::pca::QUICSVDPolicy::Epsilon
double & Epsilon()
Modify the error tolerance fraction for calculated subspace.
Definition:
quic_svd_method.hpp:78
Generated by
1.8.17