pub struct MinMaxScaler { /* private fields */ }Expand description
Scales features to a given range (default [0, 1]).
§Formula
For each feature column x:
z = (x - x_min) / (x_max - x_min) * (max_range - min_range) + min_rangewhere:
x_minis the minimum value seen during fittingx_maxis the maximum value seen during fittingmax_rangeandmin_rangeare the target range bounds
§When to Use
- When you need bounded feature ranges
- For neural networks (input normalization)
- When preserving zero values is important
- For visualization purposes
§Handling Constant Features
If a feature has zero range (all values identical), the scaler sets the scale factor to 1.0 to avoid division by zero.
Implementations§
Source§impl MinMaxScaler
impl MinMaxScaler
Sourcepub fn with_range(min: f64, max: f64) -> Self
pub fn with_range(min: f64, max: f64) -> Self
Trait Implementations§
Source§impl Clone for MinMaxScaler
impl Clone for MinMaxScaler
Source§fn clone(&self) -> MinMaxScaler
fn clone(&self) -> MinMaxScaler
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 MinMaxScaler
impl Debug for MinMaxScaler
Source§impl Default for MinMaxScaler
impl Default for MinMaxScaler
Source§impl<'de> Deserialize<'de> for MinMaxScaler
impl<'de> Deserialize<'de> for MinMaxScaler
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 MinMaxScaler
impl Scaler for MinMaxScaler
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 MinMaxScaler
impl RefUnwindSafe for MinMaxScaler
impl Send for MinMaxScaler
impl Sync for MinMaxScaler
impl Unpin for MinMaxScaler
impl UnwindSafe for MinMaxScaler
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