mlpack
Functions
pca_main.cpp File Reference
#include <mlpack/prereqs.hpp>
#include <mlpack/core/util/io.hpp>
#include <mlpack/core/util/mlpack_main.hpp>
#include "pca.hpp"
#include <mlpack/methods/pca/decomposition_policies/exact_svd_method.hpp>
#include <mlpack/methods/pca/decomposition_policies/quic_svd_method.hpp>
#include <mlpack/methods/pca/decomposition_policies/randomized_svd_method.hpp>
#include <mlpack/methods/pca/decomposition_policies/randomized_block_krylov_method.hpp>
Include dependency graph for pca_main.cpp:
This graph shows which files directly or indirectly include this file:

Functions

 BINDING_NAME ("Principal Components Analysis")
 
 BINDING_SHORT_DESC ("An implementation of several strategies for principal components analysis " "(PCA), a common preprocessing step. Given a dataset and a desired new " "dimensionality, this can reduce the dimensionality of the data using the " "linear transformation determined by PCA.")
 
 BINDING_LONG_DESC ("This program performs principal components analysis on the given dataset " "using the exact, randomized, randomized block Krylov, or QUIC SVD method. " "It will transform the data onto its principal components, optionally " "performing dimensionality reduction by ignoring the principal components " "with the smallest eigenvalues." "\" "Use the "+PRINT_PARAM_STRING("input")+" parameter to specify the " "dataset to perform PCA on. A desired new dimensionality can be specified " "with the "+PRINT_PARAM_STRING("new_dimensionality")+" parameter, or " "the desired variance to retain can be specified with the "+PRINT_PARAM_STRING("var_to_retain")+" parameter. If desired, the " "dataset can be scaled before running PCA with the "+PRINT_PARAM_STRING("scale")+" parameter." "\" "Multiple different decomposition techniques can be used. The method to " "use can be specified with the "+PRINT_PARAM_STRING("decomposition_method")+" parameter, and it may take " "the values 'exact', 'randomized', or 'quic'.")
 
 BINDING_EXAMPLE ("For example, to reduce the dimensionality of the matrix "+PRINT_DATASET("data")+" to 5 dimensions using randomized SVD for the " "decomposition, storing the output matrix to "+PRINT_DATASET("data_mod")+", the following command can be used:" "\"+PRINT_CALL("pca", "input", "data", "new_dimensionality", 5, "decomposition_method", "randomized", "output", "data_mod"))
 
 BINDING_SEE_ALSO ("Principal component analysis on Wikipedia", "https://en.wikipedia.org/wiki/Principal_component_analysis")
 
 BINDING_SEE_ALSO ("mlpack::pca::PCA C++ class documentation", "@doxygen/classmlpack_1_1pca_1_1PCA.html")
 
 PARAM_MATRIX_IN_REQ ("input", "Input dataset to perform PCA on.", "i")
 
 PARAM_MATRIX_OUT ("output", "Matrix to save modified dataset to.", "o")
 
 PARAM_INT_IN ("new_dimensionality", "Desired dimensionality of output dataset. " "If 0, no dimensionality reduction is performed.", "d", 0)
 
 PARAM_DOUBLE_IN ("var_to_retain", "Amount of variance to retain; should be " "between 0 and 1. If 1, all variance is retained. Overrides -d.", "r", 0)
 
 PARAM_FLAG ("scale", "If set, the data will be scaled before running PCA, such " "that the variance of each feature is 1.", "s")
 
 PARAM_STRING_IN ("decomposition_method", "Method used for the principal " "components analysis: 'exact', 'randomized', 'randomized-block-krylov', " "'quic'.", "c", "exact")
 
template<typename DecompositionPolicy >
void RunPCA (arma::mat &dataset, const size_t newDimension, const bool scale, const double varToRetain)
 Run RunPCA on the specified dataset with the given decomposition method.
 

Detailed Description

Author
Ryan Curtin
Marcus Edel

Main executable to run PCA.

mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license. You should have received a copy of the 3-clause BSD license along with mlpack. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information.