pub enum KernelFunction {
Linear,
Rbf {
gamma: Float,
},
Polynomial {
degree: i32,
gamma: Float,
coef0: Float,
},
Sigmoid {
gamma: Float,
coef0: Float,
},
Laplacian {
gamma: Float,
},
ChiSquared {
gamma: Float,
},
}Expand description
Kernel functions for Kernel PCA
Variants§
Linear
Linear kernel: K(x, y) = <x, y>
Rbf
RBF (Gaussian) kernel: K(x, y) = exp(-gamma * ||x - y||^2)
Polynomial
Polynomial kernel: K(x, y) = (gamma * <x, y> + coef0)^degree
Sigmoid
Sigmoid kernel: K(x, y) = tanh(gamma * <x, y> + coef0)
Laplacian
Laplacian kernel: K(x, y) = exp(-gamma * ||x - y||_1)
ChiSquared
Chi-squared kernel: K(x, y) = exp(-gamma * sum((x_i - y_i)^2 / (x_i + y_i)))
Implementations§
Source§impl KernelFunction
Kernel selection and validation utilities
impl KernelFunction
Kernel selection and validation utilities
Sourcepub fn evaluate_performance(
&self,
x: &Array2<Float>,
n_components: usize,
cv_folds: usize,
) -> Result<Float>
pub fn evaluate_performance( &self, x: &Array2<Float>, n_components: usize, cv_folds: usize, ) -> Result<Float>
Evaluate kernel performance on given data using cross-validation
Sourcepub fn select_best_kernel(
kernels: &[KernelFunction],
x: &Array2<Float>,
n_components: usize,
cv_folds: usize,
) -> Result<(KernelFunction, Float)>
pub fn select_best_kernel( kernels: &[KernelFunction], x: &Array2<Float>, n_components: usize, cv_folds: usize, ) -> Result<(KernelFunction, Float)>
Select best kernel from a list of candidates using cross-validation
Sourcepub fn generate_kernel_grid() -> Vec<KernelFunction>
pub fn generate_kernel_grid() -> Vec<KernelFunction>
Generate a grid of kernel candidates for hyperparameter tuning
Trait Implementations§
Source§impl Clone for KernelFunction
impl Clone for KernelFunction
Source§fn clone(&self) -> KernelFunction
fn clone(&self) -> KernelFunction
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for KernelFunction
Source§impl Debug for KernelFunction
impl Debug for KernelFunction
Auto Trait Implementations§
impl Freeze for KernelFunction
impl RefUnwindSafe for KernelFunction
impl Send for KernelFunction
impl Sync for KernelFunction
impl Unpin for KernelFunction
impl UnsafeUnpin for KernelFunction
impl UnwindSafe for KernelFunction
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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