Struct petal_decomposition::RandomizedPcaBuilder
source · [−]pub struct RandomizedPcaBuilder<R> { /* private fields */ }
Expand description
Builder for RandomizedPca
.
Examples
use petal_decomposition::RandomizedPcaBuilder;
let x = ndarray::arr2(&[[0_f64, 0_f64], [1_f64, 1_f64]]);
let mut pca = RandomizedPcaBuilder::new(1).build();
pca.fit(&x);
Implementations
sourceimpl RandomizedPcaBuilder<Pcg>
impl RandomizedPcaBuilder<Pcg>
sourcepub fn new(n_components: usize) -> Self
pub fn new(n_components: usize) -> Self
Sets the number of components for PCA.
The random matrix for randomized SVD is created from a PCG random number generator (the XSL 128/64 (MCG) variant on a 64-bit CPU and the XSH RR 64/32 (LCG) variant on a 32-bit CPU), initialized with a randomly-generated seed.
sourcepub fn seed(self, seed: u128) -> Self
pub fn seed(self, seed: u128) -> Self
Initialized the PCG random number genernator with the given seed.
Examples
use petal_decomposition::RandomizedPcaBuilder;
let x = ndarray::arr2(&[[0_f64, 0_f64], [1_f64, 1_f64]]);
let mut pca = RandomizedPcaBuilder::new(1).seed(1234567891011121314).build();
pca.fit(&x);
sourcepub fn centering(self, centering: bool) -> Self
pub fn centering(self, centering: bool) -> Self
Indicates whether or not to perform mean-centering on input data. It is
enabled by default. If the inputs are already centered, set centering
to false
. Note Pca::mean()
will return an Array1
of 0’s if
centering
is false
.
Examples
use petal_decomposition::RandomizedPcaBuilder;
let x = ndarray::arr2(&[[0_f64, 0_f64], [1_f64, 1_f64]]);
let mut pca = RandomizedPcaBuilder::new(1).centering(false).build();
pca.fit(&x);
sourceimpl<R: Rng> RandomizedPcaBuilder<R>
impl<R: Rng> RandomizedPcaBuilder<R>
sourcepub fn with_rng(rng: R, n_components: usize) -> Self
pub fn with_rng(rng: R, n_components: usize) -> Self
Sets the number of components and random number generator for PCA.
The random number generator is used to create a random matrix for randomized SVD.
Examples
use petal_decomposition::RandomizedPcaBuilder;
use rand_pcg::Pcg64;
let x = ndarray::arr2(&[[0_f64, 0_f64], [1_f64, 1_f64]]);
let rng = Pcg64::new(0xcafef00dd15ea5e5, 0xa02bdbf7bb3c0a7ac28fa16a64abf96);
let mut pca = RandomizedPcaBuilder::with_rng(rng, 1).build();
pca.fit(&x);
sourcepub fn build<A: Scalar>(self) -> RandomizedPca<A, R>
pub fn build<A: Scalar>(self) -> RandomizedPca<A, R>
Creates an instance of RandomizedPca
.
Auto Trait Implementations
impl<R> RefUnwindSafe for RandomizedPcaBuilder<R> where
R: RefUnwindSafe,
impl<R> Send for RandomizedPcaBuilder<R> where
R: Send,
impl<R> Sync for RandomizedPcaBuilder<R> where
R: Sync,
impl<R> Unpin for RandomizedPcaBuilder<R> where
R: Unpin,
impl<R> UnwindSafe for RandomizedPcaBuilder<R> where
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more