pub struct MaxAbsScaler<F> { /* private fields */ }Expand description
An unfitted max-absolute scaler.
Calling Fit::fit learns the per-column maximum absolute values and
returns a FittedMaxAbsScaler that can transform new data.
Columns where the maximum absolute value is zero are left unchanged after transformation.
§Examples
use ferrolearn_preprocess::MaxAbsScaler;
use ferrolearn_core::traits::{Fit, Transform};
use ndarray::array;
let scaler = MaxAbsScaler::<f64>::new();
let x = array![[-3.0, 1.0], [0.0, -2.0], [2.0, 4.0]];
let fitted = scaler.fit(&x, &()).unwrap();
let scaled = fitted.transform(&x).unwrap();
// All values now in [-1, 1]Implementations§
Trait Implementations§
Source§impl<F: Clone> Clone for MaxAbsScaler<F>
impl<F: Clone> Clone for MaxAbsScaler<F>
Source§fn clone(&self) -> MaxAbsScaler<F>
fn clone(&self) -> MaxAbsScaler<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for MaxAbsScaler<F>
impl<F: Debug> Debug for MaxAbsScaler<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for MaxAbsScaler<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for MaxAbsScaler<F>
Source§fn fit(
&self,
x: &Array2<F>,
_y: &(),
) -> Result<FittedMaxAbsScaler<F>, FerroError>
fn fit( &self, x: &Array2<F>, _y: &(), ) -> Result<FittedMaxAbsScaler<F>, FerroError>
Fit the scaler by computing per-column maximum absolute values.
§Errors
Returns FerroError::InsufficientSamples if the input has zero rows.
Source§type Fitted = FittedMaxAbsScaler<F>
type Fitted = FittedMaxAbsScaler<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F: Float + Send + Sync + 'static> FitTransform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for MaxAbsScaler<F>
impl<F: Float + Send + Sync + 'static> FitTransform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for MaxAbsScaler<F>
Source§fn fit_transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn fit_transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Fit the scaler on x and return the scaled output in one step.
§Errors
Returns an error if fitting fails (e.g., zero rows).
Source§type FitError = FerroError
type FitError = FerroError
Source§impl<F: Float + Send + Sync + 'static> PipelineTransformer<F> for MaxAbsScaler<F>
impl<F: Float + Send + Sync + 'static> PipelineTransformer<F> for MaxAbsScaler<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
_y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineTransformer<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, _y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineTransformer<F>>, FerroError>
Source§impl<F: Float + Send + Sync + 'static> Transform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for MaxAbsScaler<F>
Implement Transform on the unfitted scaler to satisfy the FitTransform: Transform
supertrait bound. Calling transform on an unfitted scaler always returns an error.
impl<F: Float + Send + Sync + 'static> Transform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for MaxAbsScaler<F>
Implement Transform on the unfitted scaler to satisfy the FitTransform: Transform
supertrait bound. Calling transform on an unfitted scaler always returns an error.
Source§fn transform(&self, _x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn transform(&self, _x: &Array2<F>) -> Result<Array2<F>, FerroError>
Always returns an error — the scaler must be fitted first.
Use Fit::fit to produce a FittedMaxAbsScaler, then call
Transform::transform on that.
Source§type Error = FerroError
type Error = FerroError
transform.Auto Trait Implementations§
impl<F> Freeze for MaxAbsScaler<F>
impl<F> RefUnwindSafe for MaxAbsScaler<F>where
F: RefUnwindSafe,
impl<F> Send for MaxAbsScaler<F>where
F: Send,
impl<F> Sync for MaxAbsScaler<F>where
F: Sync,
impl<F> Unpin for MaxAbsScaler<F>where
F: Unpin,
impl<F> UnsafeUnpin for MaxAbsScaler<F>
impl<F> UnwindSafe for MaxAbsScaler<F>where
F: 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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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