MultiScaleRBFSampler

Struct MultiScaleRBFSampler 

Source
pub struct MultiScaleRBFSampler<State = Untrained> {
    pub n_components_per_scale: usize,
    pub n_scales: usize,
    pub gamma_min: Float,
    pub gamma_max: Float,
    pub manual_gammas: Vec<Float>,
    pub bandwidth_strategy: BandwidthStrategy,
    pub combination_strategy: CombinationStrategy,
    pub scale_weights: Vec<Float>,
    pub random_state: Option<u64>,
    /* private fields */
}
Expand description

Multi-scale RBF sampler that generates random Fourier features at multiple scales

This sampler generates RBF kernel approximations using multiple bandwidth parameters (gamma values) to capture patterns at different scales. Each scale captures different frequency characteristics of the data, providing a more comprehensive representation.

§Mathematical Background

For multiple scales with bandwidths γ₁, γ₂, …, γₖ, the multi-scale RBF kernel is: K(x,y) = Σᵢ wᵢ * exp(-γᵢ||x-y||²)

The random Fourier features for each scale i are: zᵢ(x) = √(2/nᵢ) * [cos(ωᵢⱼᵀx + bᵢⱼ), sin(ωᵢⱼᵀx + bᵢⱼ)] where ωᵢⱼ ~ N(0, 2γᵢI) and bᵢⱼ ~ Uniform[0, 2π]

§Examples

use sklears_kernel_approximation::{MultiScaleRBFSampler, BandwidthStrategy, CombinationStrategy};
use sklears_core::traits::{Transform, Fit, Untrained}
use scirs2_core::ndarray::array;

let x = array![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];

let sampler = MultiScaleRBFSampler::new(100)
    .n_scales(3)
    .gamma_range(0.1, 10.0)
    .bandwidth_strategy(BandwidthStrategy::LogarithmicSpacing)
    .combination_strategy(CombinationStrategy::Concatenation);

let fitted = sampler.fit(&x, &()).unwrap();
let features = fitted.transform(&x).unwrap();

MultiScaleRBFSampler

Fields§

§n_components_per_scale: usize

Number of components per scale

§n_scales: usize

Number of scales

§gamma_min: Float

Minimum gamma value

§gamma_max: Float

Maximum gamma value

§manual_gammas: Vec<Float>

Manual gamma values (used when strategy is Manual)

§bandwidth_strategy: BandwidthStrategy

Bandwidth selection strategy

§combination_strategy: CombinationStrategy

Feature combination strategy

§scale_weights: Vec<Float>

Scale weights for weighted combination

§random_state: Option<u64>

Random seed for reproducibility

Implementations§

Source§

impl MultiScaleRBFSampler<Untrained>

Source

pub fn new(n_components_per_scale: usize) -> Self

Create a new multi-scale RBF sampler

§Arguments
  • n_components_per_scale - Number of random features per scale
Source

pub fn n_scales(self, n_scales: usize) -> Self

Set the number of scales

Source

pub fn gamma_range(self, gamma_min: Float, gamma_max: Float) -> Self

Set the gamma range for automatic bandwidth selection

Source

pub fn manual_gammas(self, gammas: Vec<Float>) -> Self

Set manual gamma values

Source

pub fn bandwidth_strategy(self, strategy: BandwidthStrategy) -> Self

Set the bandwidth selection strategy

Source

pub fn combination_strategy(self, strategy: CombinationStrategy) -> Self

Set the feature combination strategy

Source

pub fn scale_weights(self, weights: Vec<Float>) -> Self

Set weights for different scales (used in weighted combination)

Source

pub fn random_state(self, seed: u64) -> Self

Set the random state for reproducibility

Trait Implementations§

Source§

impl<State: Clone> Clone for MultiScaleRBFSampler<State>

Source§

fn clone(&self) -> MultiScaleRBFSampler<State>

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<State: Debug> Debug for MultiScaleRBFSampler<State>

Source§

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

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

impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for MultiScaleRBFSampler<Untrained>

Source§

type Fitted = MultiScaleRBFSampler<Trained>

The fitted model type
Source§

fn fit(self, x: &Array2<Float>, _y: &()) -> Result<Self::Fitted>

Fit the model to the provided data with validation
Source§

fn fit_with_validation( self, x: &X, y: &Y, _x_val: Option<&X>, _y_val: Option<&Y>, ) -> Result<(Self::Fitted, FitMetrics), SklearsError>
where Self: Sized,

Fit with custom validation and early stopping
Source§

impl Transform<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>> for MultiScaleRBFSampler<Trained>

Source§

fn transform(&self, x: &Array2<Float>) -> Result<Array2<Float>>

Transform the input data

Auto Trait Implementations§

§

impl<State> Freeze for MultiScaleRBFSampler<State>

§

impl<State> RefUnwindSafe for MultiScaleRBFSampler<State>
where State: RefUnwindSafe,

§

impl<State> Send for MultiScaleRBFSampler<State>
where State: Send,

§

impl<State> Sync for MultiScaleRBFSampler<State>
where State: Sync,

§

impl<State> Unpin for MultiScaleRBFSampler<State>
where State: Unpin,

§

impl<State> UnwindSafe for MultiScaleRBFSampler<State>
where State: UnwindSafe,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V