pub struct StandardScaler { /* private fields */ }Expand description
Standardizes features by removing the mean and scaling to unit variance.
§Formula
For each feature column x:
z = (x - μ) / σwhere:
μis the mean of the featureσis the standard deviation (σ² + ε)¹ᐟ²εis a small constant for numerical stability
§When to Use
- When features have different scales
- For algorithms sensitive to feature magnitude (not tree-based)
- When you want zero-centered data
§Notes
Trees are scale-invariant, so scaling is optional for gradient boosting. However, it can help with regularization and numerical stability.
Implementations§
Source§impl StandardScaler
impl StandardScaler
Sourcepub fn with_epsilon(epsilon: f64) -> Self
pub fn with_epsilon(epsilon: f64) -> Self
Creates a new StandardScaler with custom epsilon.
§Parameters
epsilon: Small constant added to denominator for numerical stability. Set to 1e-8 by default. Increase for very small features.
Trait Implementations§
Source§impl Clone for StandardScaler
impl Clone for StandardScaler
Source§fn clone(&self) -> StandardScaler
fn clone(&self) -> StandardScaler
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 StandardScaler
impl Debug for StandardScaler
Source§impl Default for StandardScaler
impl Default for StandardScaler
Source§impl<'de> Deserialize<'de> for StandardScaler
impl<'de> Deserialize<'de> for StandardScaler
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Scaler for StandardScaler
impl Scaler for StandardScaler
Source§fn fit(&mut self, data: &FeatureMatrix) -> DataResult<()>
fn fit(&mut self, data: &FeatureMatrix) -> DataResult<()>
Learns scaling parameters from the training data. Read more
Source§fn transform(&self, data: &FeatureMatrix) -> DataResult<FeatureMatrix>
fn transform(&self, data: &FeatureMatrix) -> DataResult<FeatureMatrix>
Applies learned transformation to data. Read more
Source§fn fit_transform(&mut self, data: &FeatureMatrix) -> DataResult<FeatureMatrix>
fn fit_transform(&mut self, data: &FeatureMatrix) -> DataResult<FeatureMatrix>
Fits and transforms in a single operation. Read more
Auto Trait Implementations§
impl Freeze for StandardScaler
impl RefUnwindSafe for StandardScaler
impl Send for StandardScaler
impl Sync for StandardScaler
impl Unpin for StandardScaler
impl UnwindSafe for StandardScaler
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