N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Definition acquisition_functions.hpp:16
std::vector< float > PcaComponent(const Pca &pca, int64_t index)
Component index as a unit vector of floats, for SteeringHook(). One standard deviation along it is sq...
Tensor PcaProject(const Pca &pca, const Tensor &x, bool whiten=false)
Each row's coordinates on the components: (x - mean) components^T, shape (n, components),...
Pca FitPca(const Tensor &x, int64_t components, bool center=true)
Fits the components directions of most variance.
Tensor PcaReconstruct(const Pca &pca, const Tensor &scores)
The rows that coordinates map back to: mean + scores components, shape (n, width)....
double SubspaceOverlap(const Pca &a, const Pca &b, int64_t k)
How much two PCAs' first k components span the same space: the mean squared cosine of the principal a...
double PcaSplitHalfOverlap(const Tensor &x, int64_t k, uint64_t seed=0)
Fits k components on each half of the rows, split at random, and returns their SubspaceOverlap()....
A fitted PCA.
Definition pca.hpp:30
std::vector< double > explained_variance
Each component's variance: the variance of the projections, dividing by n - 1.
Definition pca.hpp:40
std::vector< double > mean
The rows' mean, subtracted before projecting. All zeros when fitted uncentered.
Definition pca.hpp:36
std::vector< double > explained_variance_ratio
Each component's share of the total variance.
Definition pca.hpp:42
int64_t samples
How many rows it was fitted on.
Definition pca.hpp:34
int64_t num_components() const
Definition pca.hpp:46
double total_variance
The variance over every direction, the sum of the per-column variances.
Definition pca.hpp:44
int64_t width
The width of the rows it was fitted on.
Definition pca.hpp:32
std::vector< double > components
Row-major (components, width): unit directions, most variance first.
Definition pca.hpp:38
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).