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§
Sourcefn kernel(&self, x: &[Float], y: &[Float]) -> Float
fn kernel(&self, x: &[Float], y: &[Float]) -> Float
Compute the kernel value between two vectors
Sourcefn fourier_transform(&self, w: &[Float]) -> Float
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
Sourcefn sample_frequencies(
&self,
n_features: usize,
n_components: usize,
rng: &mut RealStdRng,
) -> Array2<Float>
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)
Sourcefn description(&self) -> String
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.