pub struct Pca<F> { /* private fields */ }Expand description
Fitted Principal Component Analysis model
The model contains the mean and hyperplane for the projection of data.
§Example
use linfa::traits::{Fit, Predict};
use linfa_reduction::Pca;
let dataset = linfa_datasets::iris();
// apply PCA projection along a line which maximizes the spread of the data
let embedding = Pca::params(1)
.fit(&dataset).unwrap();
// reduce dimensionality of the dataset
let dataset = embedding.predict(dataset);Implementations§
Source§impl Pca<f64>
impl Pca<f64>
Sourcepub fn explained_variance(&self) -> Array1<f64>
pub fn explained_variance(&self) -> Array1<f64>
Return the amount of explained variance per element
Sourcepub fn explained_variance_ratio(&self) -> Array1<f64>
pub fn explained_variance_ratio(&self) -> Array1<f64>
Return the normalized amount of explained variance per element
Sourcepub fn components(&self) -> &Array2<f64>
pub fn components(&self) -> &Array2<f64>
Return the components
Sourcepub fn singular_values(&self) -> &Array1<f64>
pub fn singular_values(&self) -> &Array1<f64>
Return the singular values
Trait Implementations§
Source§impl<F: Float, D: Data<Elem = F>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for Pca<F>
impl<F: Float, D: Data<Elem = F>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for Pca<F>
Source§impl<F: Float, D: Data<Elem = F>, T> Transformer<DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>, DatasetBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, T>> for Pca<F>
impl<F: Float, D: Data<Elem = F>, T> Transformer<DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>, DatasetBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, T>> for Pca<F>
fn transform( &self, ds: DatasetBase<ArrayBase<D, Ix2>, T>, ) -> DatasetBase<Array2<F>, T>
impl<F> StructuralPartialEq for Pca<F>
Auto Trait Implementations§
impl<F> Freeze for Pca<F>
impl<F> RefUnwindSafe for Pca<F>where
F: RefUnwindSafe,
impl<F> Send for Pca<F>where
F: Send,
impl<F> Sync for Pca<F>where
F: Sync,
impl<F> Unpin for Pca<F>
impl<F> UnwindSafe for Pca<F>where
F: RefUnwindSafe,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for Owhere
R: Records<Elem = F>,
O: PredictInplace<R, S>,
impl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for Owhere
R: Records<Elem = F>,
O: PredictInplace<R, S>,
fn predict(&self, ds: &'a DatasetBase<R, T>) -> S
Source§impl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for O
impl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for O
Source§impl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for O
impl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for O
fn predict(&self, ds: DatasetBase<R, T>) -> DatasetBase<R, S>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.