petal-decomposition 0.1.0

Principal component analysis (PCA).
docs.rs failed to build petal-decomposition-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: petal-decomposition-0.6.2

petal-decomposition

Principal Component Analysis.

Coverage Status

Requirements

  • Rust ≥ 1.38

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 ndarray::arr2;
use petal_decomposition::Pca;

let x = arr2(&[[0_f64, 0_f64], [1_f64, 1_f64], [2_f64, 2_f64]]);
let pca = Pca::new(2);                   // Keep two dimensions.
pca.fit(&x).unwrap();

let s = pca.singular_values();           // [2_f64, 0_f64]
let v = pca.explained_variance_ratio();  // [1_f64, 0_f64]
let y = pca.transform(&x).unwrap();      // [-2_f64.sqrt(), 0_f64, 2_f64.sqrt()]