pub struct RandomFourierFeatures { /* private fields */ }Expand description
Random Fourier Features for scalable kernel approximation.
This struct stores the random frequencies sampled from the spectral distribution of the kernel, allowing efficient feature computation.
Implementations§
Source§impl RandomFourierFeatures
impl RandomFourierFeatures
Sourcepub fn new(input_dim: usize, config: RffConfig) -> Result<Self>
pub fn new(input_dim: usize, config: RffConfig) -> Result<Self>
Create a new Random Fourier Features transformer.
§Arguments
input_dim- Dimension of input vectorsconfig- RFF configuration
§Example
use tensorlogic_sklears_kernels::random_features::{
RandomFourierFeatures, RffConfig, KernelType
};
let config = RffConfig::new(KernelType::Rbf { gamma: 1.0 }, 50);
let rff = RandomFourierFeatures::new(10, config).unwrap();Sourcepub fn approximate_kernel(&self, x: &[f64], y: &[f64]) -> Result<f64>
pub fn approximate_kernel(&self, x: &[f64], y: &[f64]) -> Result<f64>
Approximate the kernel value between two vectors.
K(x, y) ≈ z(x)^T z(y)
Sourcepub fn approximate_kernel_matrix(
&self,
data: &[Vec<f64>],
) -> Result<Vec<Vec<f64>>>
pub fn approximate_kernel_matrix( &self, data: &[Vec<f64>], ) -> Result<Vec<Vec<f64>>>
Approximate the kernel matrix for a set of data points.
K[i,j] ≈ z(x_i)^T z(x_j)
Sourcepub fn output_dim(&self) -> usize
pub fn output_dim(&self) -> usize
Get the output dimension (feature space dimension).
Sourcepub fn n_components(&self) -> usize
pub fn n_components(&self) -> usize
Get the number of random components.
Sourcepub fn kernel_type(&self) -> &KernelType
pub fn kernel_type(&self) -> &KernelType
Get the kernel type being approximated.
Sourcepub fn random_weights(&self) -> &[Vec<f64>]
pub fn random_weights(&self) -> &[Vec<f64>]
Get the random weights matrix.
Trait Implementations§
Source§impl Clone for RandomFourierFeatures
impl Clone for RandomFourierFeatures
Source§fn clone(&self) -> RandomFourierFeatures
fn clone(&self) -> RandomFourierFeatures
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RandomFourierFeatures
impl RefUnwindSafe for RandomFourierFeatures
impl Send for RandomFourierFeatures
impl Sync for RandomFourierFeatures
impl Unpin for RandomFourierFeatures
impl UnwindSafe for RandomFourierFeatures
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
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