pub struct PCA { /* private fields */ }Expand description
Principal Component Analysis (PCA) for dimensionality reduction.
PCA reduces dimensionality by projecting data onto principal components (directions of maximum variance).
§Example
use aprender::preprocessing::PCA;
use aprender::traits::Transformer;
use aprender::primitives::Matrix;
let data = Matrix::from_vec(4, 3, vec![
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0,
10.0, 11.0, 12.0,
]).expect("valid matrix dimensions");
let mut pca = PCA::new(2); // Reduce to 2 components
let transformed = pca.fit_transform(&data).expect("fit_transform should succeed");
assert_eq!(transformed.shape(), (4, 2));Implementations§
Source§impl PCA
impl PCA
Sourcepub fn explained_variance(&self) -> Option<&[f32]>
pub fn explained_variance(&self) -> Option<&[f32]>
Returns the variance explained by each component.
Sourcepub fn explained_variance_ratio(&self) -> Option<&[f32]>
pub fn explained_variance_ratio(&self) -> Option<&[f32]>
Returns the ratio of variance explained by each component.
Sourcepub fn components(&self) -> Option<&Matrix<f32>>
pub fn components(&self) -> Option<&Matrix<f32>>
Returns the principal components.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PCA
impl RefUnwindSafe for PCA
impl Send for PCA
impl Sync for PCA
impl Unpin for PCA
impl UnsafeUnpin for PCA
impl UnwindSafe for PCA
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more