7#include "../utils/matrix.hpp"
17 using namespace utils;
100 std::vector<T> singular_values_;
101 std::vector<T> explained_variance_;
102 std::vector<T> explained_variance_ratio_;
103 std::vector<T> mean_;
104 std::vector<T> scale_;
105 bool is_fitted_ =
false;
void fit(const Matrix< T > &data, bool center=true, bool scale=false)
Fit the PCA model to the data.
PCA()=default
Default constructor.
std::vector< T > singular_values() const
Get the singular values (square roots of eigenvalues)
Matrix< T > components() const
Get the principal components (eigenvectors)
std::vector< T > explained_variance_ratio() const
Get the explained variance ratio for each component.
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.
Namespace containing traditional machine learning algorithms.