petal-decomposition
petal-decomposition provides matrix decomposition algorithms including PCA (principal component analysis) and ICA (independent component analysis).
Requirements
- Rust ≥ 1.38
- BLAS/LAPACK backend (OpenBLAS, Netlib, or Intel MKL)
Features
- PCA with exact, full SVD (singular value decomposition)
- PCA with randomized, truncated SVD
- FastICA
Crate Features
intel-mkl,netlib, andopenblasare used to select a BLAS/LAPACK backend. By default,intel-mklis used.serializationenables serialization/deserialization using serde.
Examples
The following example shows how to apply PCA to an array of three samples, and obtain singular values as well as how much variance each component explains.
use arr2;
use Pca;
let x = arr2;
let mut pca = new; // Keep two dimensions.
pca.fit.unwrap;
let s = pca.singular_values; // [2_f64, 0_f64]
let v = pca.explained_variance_ratio; // [1_f64, 0_f64]
let y = pca.transform.unwrap; // [-2_f64.sqrt(), 0_f64, 2_f64.sqrt()]