petal-decomposition

Crates.iopetal-decomposition
lib.rspetal-decomposition
version0.8.0
sourcesrc
created_at2020-05-21 00:14:42.187869
updated_at2024-11-01 18:31:54.042445
descriptionMatrix decomposition algorithms including PCA (principal component analysis) and ICA (independent component analysis)
homepagehttps://github.com/petabi/petal-decomposition
repositoryhttps://github.com/petabi/petal-decomposition
max_upload_size
id243983
size86,701
(minshao)

documentation

https://docs.rs/petal-decomposition

README

petal-decomposition

petal-decomposition provides matrix decomposition algorithms including PCA (principal component analysis) and ICA (independent component analysis).

crates.io Documentation Coverage Status

Requirements

  • BLAS/LAPACK backend (OpenBLAS, Netlib, Intel MKL, or the Accelerate Framework)

Features

  • PCA with exact, full SVD (singular value decomposition)
  • PCA with randomized, truncated SVD
  • FastICA

Crate Features

  • Use one of intel-mkl-static, intel-mkl-system, netlib-static, netlib-system, openblas-static, and openblas-system to select a BLAS/LAPACK backend. See ndarray-linalg's documentation for details.

    Note: On macOS, the Accelerate Framework is used by default, so these features are not needed.

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

let x = arr2(&[[0_f64, 0_f64], [1_f64, 1_f64], [2_f64, 2_f64]]);
let mut pca = PcaBuilder::new(2).build(); // 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()]

License

Copyright 2020-2024 Petabi, Inc.

Licensed under Apache License, Version 2.0 (the "License"); you may not use this crate except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See LICENSE for the specific language governing permissions and limitations under the License.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Commit count: 104

cargo fmt