Struct linfa_reduction::Pca
source · [−]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
sourceimpl 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 singular_values(&self) -> &Array1<f64>
pub fn singular_values(&self) -> &Array1<f64>
Return the singular values
Trait Implementations
sourceimpl<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>
sourcefn predict_inplace(&self, records: &ArrayBase<D, Ix2>, targets: &mut Array2<F>)
fn predict_inplace(&self, records: &ArrayBase<D, Ix2>, targets: &mut Array2<F>)
Predict something in place
sourcefn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array2<F>
fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array2<F>
Create targets that predict_inplace works with.
sourceimpl<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>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'a, F, D, DM, T, O> Predict<&'a ArrayBase<D, DM>, T> for O where
D: Data<Elem = F>,
DM: Dimension,
O: PredictInplace<ArrayBase<D, DM>, T>,
impl<'a, F, D, DM, T, O> Predict<&'a ArrayBase<D, DM>, T> for O where
D: Data<Elem = F>,
DM: Dimension,
O: PredictInplace<ArrayBase<D, DM>, T>,
sourceimpl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for O where
R: Records<Elem = F>,
O: PredictInplace<R, S>,
impl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for O where
R: Records<Elem = F>,
O: PredictInplace<R, S>,
pub fn predict(&self, ds: &'a DatasetBase<R, T>) -> S
sourceimpl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for O where
D: Data<Elem = F>,
T: AsTargets<Elem = E>,
O: PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, T>,
impl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for O where
D: Data<Elem = F>,
T: AsTargets<Elem = E>,
O: PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, T>,
sourceimpl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for O where
R: Records<Elem = F>,
S: AsTargets<Elem = E>,
O: PredictInplace<R, S>,
impl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for O where
R: Records<Elem = F>,
S: AsTargets<Elem = E>,
O: PredictInplace<R, S>,
pub fn predict(&self, ds: DatasetBase<R, T>) -> DatasetBase<R, S>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more