pub struct RandomFourierFeatures { /* private fields */ }Expand description
let X = array![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]; let mut rff = RandomFourierFeatures::new(100, 1.0, Some(42)); rff.fit(&X.view()).unwrap(); let features = rff.transform(&X.view()).unwrap();
Implementations§
Source§impl RandomFourierFeatures
impl RandomFourierFeatures
Sourcepub fn new(n_components: usize, gamma: f64, random_state: Option<u64>) -> Self
pub fn new(n_components: usize, gamma: f64, random_state: Option<u64>) -> Self
Create a new RandomFourierFeatures instance
§Parameters
n_components- Number of random features to generategamma- Parameter of the RBF kernel (gamma = 1 / (2 * sigma^2))random_state- Random seed for reproducibility
Sourcepub fn fit(&mut self, X: &ArrayView2<'_, f64>) -> SklResult<()>
pub fn fit(&mut self, X: &ArrayView2<'_, f64>) -> SklResult<()>
Fit the random Fourier features to the training data
Sourcepub fn transform(&self, X: &ArrayView2<'_, f64>) -> SklResult<Array2<f64>>
pub fn transform(&self, X: &ArrayView2<'_, f64>) -> SklResult<Array2<f64>>
Transform the input data to the random feature space
Sourcepub fn fit_transform(
&mut self,
X: &ArrayView2<'_, f64>,
) -> SklResult<Array2<f64>>
pub fn fit_transform( &mut self, X: &ArrayView2<'_, f64>, ) -> SklResult<Array2<f64>>
Fit and transform in one step
Sourcepub fn n_components(&self) -> usize
pub fn n_components(&self) -> usize
Get the number of components
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 moreSource§impl Debug for RandomFourierFeatures
impl Debug for RandomFourierFeatures
Auto 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