pub struct MinMaxScaler { /* private fields */ }Expand description
Scales features to a given range (default [0, 1]).
The transformation is: X_scaled = (X - X_min) / (X_max - X_min)
This transformer is useful for algorithms sensitive to feature scales and when you want bounded outputs (e.g., for neural networks).
§Example
use aprender::prelude::*;
use aprender::preprocessing::MinMaxScaler;
let data = Matrix::from_vec(3, 2, vec![
0.0, 0.0,
5.0, 10.0,
10.0, 20.0,
]).expect("valid matrix dimensions");
let mut scaler = MinMaxScaler::new();
let scaled = scaler.fit_transform(&data).expect("fit_transform should succeed");
// Verify scaling to [0, 1]
assert!((scaled.get(0, 0) - 0.0).abs() < 1e-6);
assert!((scaled.get(2, 0) - 1.0).abs() < 1e-6);
assert!((scaled.get(1, 0) - 0.5).abs() < 1e-6);Implementations§
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§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 Serialize for MinMaxScaler
impl Serialize for MinMaxScaler
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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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