Deep Learning Algorithm Implementations 1.0.0
C++ implementations of fundamental deep learning algorithms
|
#include <pca.hpp>
Public Member Functions | |
PCA ()=default | |
Default constructor. | |
void | fit (const Matrix< T > &data, bool center=true, bool scale=false) |
Fit the PCA model to the data. | |
Matrix< T > | transform (const Matrix< T > &data, size_t n_components=0) const |
Transform data to the principal component space. | |
Matrix< T > | fit_transform (const Matrix< T > &data, size_t n_components=0, bool center=true, bool scale=false) |
Fit the model and transform the data in one step. | |
std::vector< T > | explained_variance_ratio () const |
Get the explained variance ratio for each component. | |
Matrix< T > | components () const |
Get the principal components (eigenvectors) | |
std::vector< T > | singular_values () const |
Get the singular values (square roots of eigenvalues) | |
Default constructor.
Get the principal components (eigenvectors)
Get the explained variance ratio for each component.
void ml::PCA< T >::fit | ( | const Matrix< T > & | data, |
bool | center = true , |
||
bool | scale = false |
||
) |
Matrix< T > ml::PCA< T >::fit_transform | ( | const Matrix< T > & | data, |
size_t | n_components = 0 , |
||
bool | center = true , |
||
bool | scale = false |
||
) |
Fit the model and transform the data in one step.
data | Input data matrix where rows are samples and columns are features |
n_components | Number of components to keep (if 0, keep all components) |
center | Whether to center the data before computing PCA |
scale | Whether to scale the data to unit variance before computing PCA |
Get the singular values (square roots of eigenvalues)
Matrix< T > ml::PCA< T >::transform | ( | const Matrix< T > & | data, |
size_t | n_components = 0 |
||
) | const |
Transform data to the principal component space.
data | Input data matrix where rows are samples and columns are features |
n_components | Number of components to keep (if 0, keep all components) |