pub struct KernelPCA<F> { /* private fields */ }Expand description
Kernel PCA configuration.
Holds hyperparameters for the kernel PCA decomposition. Calling
Fit::fit computes the kernel eigendecomposition and returns a
FittedKernelPCA that can project new data via Transform::transform.
Implementations§
Source§impl<F: Float + Send + Sync + 'static> KernelPCA<F>
impl<F: Float + Send + Sync + 'static> KernelPCA<F>
Sourcepub fn new(n_components: usize) -> Self
pub fn new(n_components: usize) -> Self
Create a new KernelPCA that retains n_components components.
Defaults: kernel=Linear, gamma=None (auto: 1/n_features),
degree=3, coef0=0.
Sourcepub fn with_kernel(self, kernel: Kernel) -> Self
pub fn with_kernel(self, kernel: Kernel) -> Self
Set the kernel function.
Sourcepub fn with_gamma(self, gamma: f64) -> Self
pub fn with_gamma(self, gamma: f64) -> Self
Set the gamma parameter for RBF, polynomial, and sigmoid kernels.
Sourcepub fn with_degree(self, degree: usize) -> Self
pub fn with_degree(self, degree: usize) -> Self
Set the degree for the polynomial kernel.
Sourcepub fn with_coef0(self, coef0: f64) -> Self
pub fn with_coef0(self, coef0: f64) -> Self
Set the independent term for polynomial and sigmoid kernels.
Sourcepub fn n_components(&self) -> usize
pub fn n_components(&self) -> usize
Return the configured number of components.
Trait Implementations§
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for KernelPCA<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for KernelPCA<F>
Source§fn fit(&self, x: &Array2<F>, _y: &()) -> Result<FittedKernelPCA<F>, FerroError>
fn fit(&self, x: &Array2<F>, _y: &()) -> Result<FittedKernelPCA<F>, FerroError>
Fit Kernel PCA by computing the kernel matrix, centring it in feature space, and eigendecomposing.
§Errors
FerroError::InvalidParameterifn_componentsis zero or exceeds the number of samples.FerroError::InsufficientSamplesif there are fewer than 2 samples.FerroError::ConvergenceFailureif the Jacobi eigendecomposition does not converge.
Source§type Fitted = FittedKernelPCA<F>
type Fitted = FittedKernelPCA<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Source§impl<F: Float + Send + Sync + 'static> PipelineTransformer<F> for KernelPCA<F>
impl<F: Float + Send + Sync + 'static> PipelineTransformer<F> for KernelPCA<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
_y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineTransformer<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, _y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineTransformer<F>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for KernelPCA<F>
impl<F> RefUnwindSafe for KernelPCA<F>where
F: RefUnwindSafe,
impl<F> Send for KernelPCA<F>where
F: Send,
impl<F> Sync for KernelPCA<F>where
F: Sync,
impl<F> Unpin for KernelPCA<F>where
F: Unpin,
impl<F> UnsafeUnpin for KernelPCA<F>
impl<F> UnwindSafe for KernelPCA<F>where
F: UnwindSafe,
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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