Skip to main content

KernelSelector

Struct KernelSelector 

Source
pub struct KernelSelector { /* private fields */ }
Expand description

Kernel selector for choosing and comparing kernels.

Implementations§

Source§

impl KernelSelector

Source

pub fn new() -> Self

Create a new kernel selector.

Source

pub fn with_regularization(self, reg: f64) -> Self

Set the regularization parameter.

Source

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 evaluate
  • data - Input data points
  • targets - Target values (for regression) or labels (for classification)
Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> KernelSelector

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KernelSelector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for KernelSelector

Source§

fn default() -> KernelSelector

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.