KernelFunction

Trait KernelFunction 

Source
pub trait KernelFunction:
    Clone
    + Send
    + Sync {
    // Required methods
    fn kernel(&self, x: &[Float], y: &[Float]) -> Float;
    fn fourier_transform(&self, w: &[Float]) -> Float;
    fn sample_frequencies(
        &self,
        n_features: usize,
        n_components: usize,
        rng: &mut RealStdRng,
    ) -> Array2<Float>;
    fn description(&self) -> String;
}
Expand description

Trait for defining custom kernel functions

Required Methods§

Source

fn kernel(&self, x: &[Float], y: &[Float]) -> Float

Compute the kernel value between two vectors

Source

fn fourier_transform(&self, w: &[Float]) -> Float

Get the characteristic function of the kernel’s Fourier transform This should return the Fourier transform of the kernel at frequency w For most kernels, this is needed to generate appropriate random features

Source

fn sample_frequencies( &self, n_features: usize, n_components: usize, rng: &mut RealStdRng, ) -> Array2<Float>

Sample random frequencies for Random Fourier Features This method should sample frequencies according to the spectral measure of the kernel (i.e., the Fourier transform of the kernel)

Source

fn description(&self) -> String

Get a description of the kernel

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§