15 #ifndef __MLPACK_METHODS_KERNEL_PCA_NYSTROEM_METHOD_HPP
16 #define __MLPACK_METHODS_KERNEL_PCA_NYSTROEM_METHOD_HPP
27 typename PointSelectionPolicy = kernel::KMeansSelection<>
43 arma::mat& transformedData,
47 KernelType kernel = KernelType())
53 transformedData = G.t() * G;
63 arma::colvec colMean = arma::sum(G, 1) / G.n_rows;
64 G.each_row() -= arma::sum(G, 0) / G.n_rows;
65 G.each_col() -= colMean;
66 G += arma::sum(colMean) / G.n_rows;
69 arma::eig_sym(eigval, eigvec, transformedData);
73 for (
size_t i = 0; i < floor(eigval.n_elem / 2.0); ++i)
74 eigval.swap_rows(i, (eigval.n_elem - 1) - i);
77 eigvec = arma::fliplr(eigvec);
79 transformedData = eigvec.t() * G.t();
Linear algebra utility functions, generally performed on matrices or vectors.
void Apply(arma::mat &output)
Apply the low-rank factorization to obtain an output matrix G such that K' = G * G^T.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
void Center(const arma::mat &x, arma::mat &xCentered)
Creates a centered matrix, where centering is done by subtracting the sum over the columns (a column ...
static void ApplyKernelMatrix(const arma::mat &data, arma::mat &transformedData, arma::vec &eigval, arma::mat &eigvec, const size_t rank, KernelType kernel=KernelType())
Construct the kernel matrix approximation using the nystroem method.