pub struct SparsePolynomialFeatures<State = Untrained> { /* private fields */ }Expand description
SparsePolynomialFeatures generates sparse polynomial and interaction features
This is a memory-efficient version of PolynomialFeatures designed for high-dimensional data. Instead of storing all possible polynomial combinations, it stores only the terms that would actually be non-zero, using a sparse representation.
This is particularly useful when:
- The input dimensionality is high (hundreds or thousands of features)
- Many input features are zero or near-zero
- Memory usage is a concern
- You want to limit the total number of generated features
Implementations§
Source§impl SparsePolynomialFeatures<Untrained>
impl SparsePolynomialFeatures<Untrained>
Sourcepub fn interaction_only(self, interaction_only: bool) -> Self
pub fn interaction_only(self, interaction_only: bool) -> Self
Set whether to include interaction terms only
Sourcepub fn include_bias(self, include_bias: bool) -> Self
pub fn include_bias(self, include_bias: bool) -> Self
Set whether to include bias term
Sourcepub fn min_coefficient(self, min_coefficient: Float) -> Self
pub fn min_coefficient(self, min_coefficient: Float) -> Self
Set minimum coefficient magnitude threshold
Sourcepub fn sort_terms(self, sort_terms: bool) -> Self
pub fn sort_terms(self, sort_terms: bool) -> Self
Set whether to sort terms
Source§impl SparsePolynomialFeatures<Trained>
impl SparsePolynomialFeatures<Trained>
Sourcepub fn n_features_in(&self) -> usize
pub fn n_features_in(&self) -> usize
Get the number of input features
Sourcepub fn n_output_features(&self) -> usize
pub fn n_output_features(&self) -> usize
Get the number of output features
Sourcepub fn sparse_terms(&self) -> &[SparseCoefficient]
pub fn sparse_terms(&self) -> &[SparseCoefficient]
Get the sparse terms
Sourcepub fn memory_info(&self) -> SparseMemoryInfo
pub fn memory_info(&self) -> SparseMemoryInfo
Get memory usage information
Trait Implementations§
Source§impl Default for SparsePolynomialFeatures<Untrained>
impl Default for SparsePolynomialFeatures<Untrained>
Source§impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for SparsePolynomialFeatures<Untrained>
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for SparsePolynomialFeatures<Untrained>
Source§type Fitted = SparsePolynomialFeatures<Trained>
type Fitted = SparsePolynomialFeatures<Trained>
The fitted model type
Source§fn fit(self, x: &Array2<Float>, _y: &()) -> Result<Self::Fitted>
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,
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
Auto Trait Implementations§
impl<State> Freeze for SparsePolynomialFeatures<State>
impl<State> RefUnwindSafe for SparsePolynomialFeatures<State>where
State: RefUnwindSafe,
impl<State> Send for SparsePolynomialFeatures<State>where
State: Send,
impl<State> Sync for SparsePolynomialFeatures<State>where
State: Sync,
impl<State> Unpin for SparsePolynomialFeatures<State>where
State: Unpin,
impl<State> UnwindSafe for SparsePolynomialFeatures<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
Mutably borrows from an owned value. Read more
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