pub struct KernelSelector { /* private fields */ }Expand description
Kernel selector for choosing and comparing kernels.
Implementations§
Source§impl KernelSelector
impl KernelSelector
Sourcepub fn with_regularization(self, reg: f64) -> Self
pub fn with_regularization(self, reg: f64) -> Self
Set the regularization parameter.
Sourcepub fn kernel_target_alignment<K: Kernel + ?Sized>(
&self,
kernel: &K,
data: &[Vec<f64>],
targets: &[f64],
) -> Result<f64>
pub fn kernel_target_alignment<K: Kernel + ?Sized>( &self, kernel: &K, data: &[Vec<f64>], targets: &[f64], ) -> Result<f64>
Compute Kernel Target Alignment (KTA).
KTA measures how well a kernel aligns with the target labels. Higher values indicate better alignment.
Formula: KTA = <K, yy^T>_F / (||K||_F * ||yy^T||_F)
§Arguments
kernel- The kernel to evaluatedata- Input data pointstargets- Target values (for regression) or labels (for classification)
Sourcepub fn centered_kernel_target_alignment<K: Kernel + ?Sized>(
&self,
kernel: &K,
data: &[Vec<f64>],
targets: &[f64],
) -> Result<f64>
pub fn centered_kernel_target_alignment<K: Kernel + ?Sized>( &self, kernel: &K, data: &[Vec<f64>], targets: &[f64], ) -> Result<f64>
Compute centered Kernel Target Alignment.
Centered KTA is more robust and accounts for the mean of the kernel matrix.
Sourcepub fn compare_kernels_kta(
&self,
kernels: &[(&str, &dyn Kernel)],
data: &[Vec<f64>],
targets: &[f64],
) -> Result<KernelComparison>
pub fn compare_kernels_kta( &self, kernels: &[(&str, &dyn Kernel)], data: &[Vec<f64>], targets: &[f64], ) -> Result<KernelComparison>
Compare multiple kernels using KTA.
Returns a comparison with the best kernel identified.
Sourcepub fn loo_error_estimate<K: Kernel + ?Sized>(
&self,
kernel: &K,
data: &[Vec<f64>],
targets: &[f64],
) -> Result<f64>
pub fn loo_error_estimate<K: Kernel + ?Sized>( &self, kernel: &K, data: &[Vec<f64>], targets: &[f64], ) -> Result<f64>
Evaluate kernel quality using Leave-One-Out (LOO) error estimate.
For GP regression, this provides an efficient estimate of generalization error. Lower values indicate better performance.
Note: This is an approximation based on the kernel matrix.
Sourcepub fn k_fold_cv<K: Kernel + ?Sized>(
&self,
kernel: &K,
data: &[Vec<f64>],
targets: &[f64],
config: &KFoldConfig,
) -> Result<CrossValidationResult>
pub fn k_fold_cv<K: Kernel + ?Sized>( &self, kernel: &K, data: &[Vec<f64>], targets: &[f64], config: &KFoldConfig, ) -> Result<CrossValidationResult>
Perform K-fold cross-validation for kernel evaluation.
This evaluates a kernel by training on K-1 folds and testing on the remaining fold. The score returned is based on kernel alignment with targets.
Sourcepub fn grid_search_rbf_gamma(
&self,
data: &[Vec<f64>],
targets: &[f64],
gammas: &[f64],
) -> Result<GammaSearchResult>
pub fn grid_search_rbf_gamma( &self, data: &[Vec<f64>], targets: &[f64], gammas: &[f64], ) -> Result<GammaSearchResult>
Find the best gamma for RBF kernel using grid search.
Searches over a logarithmic grid of gamma values.
Trait Implementations§
Source§impl Clone for KernelSelector
impl Clone for KernelSelector
Source§fn clone(&self) -> KernelSelector
fn clone(&self) -> KernelSelector
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KernelSelector
impl Debug for KernelSelector
Source§impl Default for KernelSelector
impl Default for KernelSelector
Source§fn default() -> KernelSelector
fn default() -> KernelSelector
Auto Trait Implementations§
impl Freeze for KernelSelector
impl RefUnwindSafe for KernelSelector
impl Send for KernelSelector
impl Sync for KernelSelector
impl Unpin for KernelSelector
impl UnwindSafe for KernelSelector
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
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>
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>
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