pub struct AdaptiveNystroem<State = Untrained> {
pub kernel: Kernel,
pub max_components: usize,
pub min_components: usize,
pub selection_strategy: ComponentSelectionStrategy,
pub error_bound_method: ErrorBoundMethod,
pub sampling_strategy: SamplingStrategy,
pub random_state: Option<u64>,
/* private fields */
}Expand description
Adaptive Nyström method with error bounds
Automatically selects the number of components based on approximation quality and provides theoretical or empirical error bounds for the kernel approximation.
§Parameters
kernel- Kernel function to approximatemax_components- Maximum number of components (default: 500)min_components- Minimum number of components (default: 10)selection_strategy- Strategy for component selectionerror_bound_method- Method for computing error boundssampling_strategy- Sampling strategy for landmark selectionrandom_state- Random seed for reproducibility
§Examples
use sklears_kernel_approximation::adaptive_nystroem::{AdaptiveNystroem, ComponentSelectionStrategy};
use sklears_kernel_approximation::nystroem::Kernel;
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 adaptive = AdaptiveNystroem::new(Kernel::Rbf { gamma: 1.0 })
.selection_strategy(ComponentSelectionStrategy::ErrorTolerance { tolerance: 0.1 });
let fitted_adaptive = adaptive.fit(&X, &()).unwrap();
let X_transformed = fitted_adaptive.transform(&X).unwrap();AdaptiveNystroem
Fields§
§kernel: KernelKernel function
max_components: usizeMaximum number of components
min_components: usizeMinimum number of components
selection_strategy: ComponentSelectionStrategyComponent selection strategy
error_bound_method: ErrorBoundMethodError bound computation method
sampling_strategy: SamplingStrategySampling strategy
random_state: Option<u64>Random seed
Implementations§
Source§impl AdaptiveNystroem<Untrained>
impl AdaptiveNystroem<Untrained>
Sourcepub fn max_components(self, max_components: usize) -> Self
pub fn max_components(self, max_components: usize) -> Self
Set the maximum number of components
Sourcepub fn min_components(self, min_components: usize) -> Self
pub fn min_components(self, min_components: usize) -> Self
Set the minimum number of components
Sourcepub fn selection_strategy(self, strategy: ComponentSelectionStrategy) -> Self
pub fn selection_strategy(self, strategy: ComponentSelectionStrategy) -> Self
Set the component selection strategy
Sourcepub fn error_bound_method(self, method: ErrorBoundMethod) -> Self
pub fn error_bound_method(self, method: ErrorBoundMethod) -> Self
Set the error bound method
Sourcepub fn sampling_strategy(self, strategy: SamplingStrategy) -> Self
pub fn sampling_strategy(self, strategy: SamplingStrategy) -> Self
Set the sampling strategy
Sourcepub fn random_state(self, seed: u64) -> Self
pub fn random_state(self, seed: u64) -> Self
Set random state for reproducibility
Source§impl AdaptiveNystroem<Trained>
impl AdaptiveNystroem<Trained>
Sourcepub fn components(&self) -> &Array2<Float>
pub fn components(&self) -> &Array2<Float>
Get the selected components
Sourcepub fn component_indices(&self) -> &[usize]
pub fn component_indices(&self) -> &[usize]
Get the component indices
Sourcepub fn n_components_selected(&self) -> usize
pub fn n_components_selected(&self) -> usize
Get the number of components selected
Sourcepub fn error_bound(&self) -> Float
pub fn error_bound(&self) -> Float
Get the error bound
Sourcepub fn eigenvalues(&self) -> &Array1<Float>
pub fn eigenvalues(&self) -> &Array1<Float>
Get the eigenvalues
Sourcepub fn approximation_rank(&self, threshold: Float) -> usize
pub fn approximation_rank(&self, threshold: Float) -> usize
Get the approximation rank (number of significant eigenvalues)
Trait Implementations§
Source§impl<State: Clone> Clone for AdaptiveNystroem<State>
impl<State: Clone> Clone for AdaptiveNystroem<State>
Source§fn clone(&self) -> AdaptiveNystroem<State>
fn clone(&self) -> AdaptiveNystroem<State>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<State: Debug> Debug for AdaptiveNystroem<State>
impl<State: Debug> Debug for AdaptiveNystroem<State>
Source§impl Estimator for AdaptiveNystroem<Untrained>
impl Estimator for AdaptiveNystroem<Untrained>
Source§type Error = SklearsError
type Error = SklearsError
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
Source§fn check_compatibility(
&self,
n_samples: usize,
n_features: usize,
) -> Result<(), SklearsError>
fn check_compatibility( &self, n_samples: usize, n_features: usize, ) -> Result<(), SklearsError>
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Source§impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for AdaptiveNystroem<Untrained>
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for AdaptiveNystroem<Untrained>
Source§type Fitted = AdaptiveNystroem<Trained>
type Fitted = AdaptiveNystroem<Trained>
Source§fn fit(self, x: &Array2<Float>, _y: &()) -> Result<Self::Fitted>
fn fit(self, x: &Array2<Float>, _y: &()) -> Result<Self::Fitted>
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,
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,
Auto Trait Implementations§
impl<State> Freeze for AdaptiveNystroem<State>
impl<State> RefUnwindSafe for AdaptiveNystroem<State>where
State: RefUnwindSafe,
impl<State> Send for AdaptiveNystroem<State>where
State: Send,
impl<State> Sync for AdaptiveNystroem<State>where
State: Sync,
impl<State> Unpin for AdaptiveNystroem<State>where
State: Unpin,
impl<State> UnwindSafe for AdaptiveNystroem<State>where
State: UnwindSafe,
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
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>
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>
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