pub struct Normalizer<F> { /* private fields */ }Expand description
A stateless row-wise normalizer.
Each sample (row) is independently scaled so that its chosen norm equals 1. Samples with a zero norm are left unchanged.
This transformer is stateless — no Fit
step is needed. Call Transform::transform directly.
§Examples
use ferrolearn_preprocess::normalizer::{Normalizer, NormType};
use ferrolearn_core::traits::Transform;
use ndarray::array;
let normalizer = Normalizer::<f64>::new(NormType::L2);
let x = array![[3.0, 4.0], [1.0, 0.0]];
let out = normalizer.transform(&x).unwrap();
// Row 0: [3/5, 4/5], Row 1: [1.0, 0.0]Implementations§
Trait Implementations§
Source§impl<F: Clone> Clone for Normalizer<F>
impl<F: Clone> Clone for Normalizer<F>
Source§fn clone(&self) -> Normalizer<F>
fn clone(&self) -> Normalizer<F>
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<F: Debug> Debug for Normalizer<F>
impl<F: Debug> Debug for Normalizer<F>
Source§impl FittedPipelineTransformer for Normalizer<f64>
impl FittedPipelineTransformer for Normalizer<f64>
Source§fn transform_pipeline(&self, x: &Array2<f64>) -> Result<Array2<f64>, FerroError>
fn transform_pipeline(&self, x: &Array2<f64>) -> Result<Array2<f64>, FerroError>
Source§impl PipelineTransformer for Normalizer<f64>
impl PipelineTransformer for Normalizer<f64>
Source§fn fit_pipeline(
&self,
_x: &Array2<f64>,
_y: &Array1<f64>,
) -> Result<Box<dyn FittedPipelineTransformer>, FerroError>
fn fit_pipeline( &self, _x: &Array2<f64>, _y: &Array1<f64>, ) -> Result<Box<dyn FittedPipelineTransformer>, FerroError>
Fit the normalizer using the pipeline interface.
Because Normalizer is stateless, this simply boxes self as a
FittedPipelineTransformer.
§Errors
This implementation never returns an error.
Source§impl<F: Float + Send + Sync + 'static> Transform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for Normalizer<F>
impl<F: Float + Send + Sync + 'static> Transform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for Normalizer<F>
Source§fn transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Normalize each row of x to unit norm.
Rows with a zero norm value are left unchanged.
§Errors
This implementation never returns an error for well-formed inputs, but
returns Ok(...) to satisfy the trait contract.
Source§type Error = FerroError
type Error = FerroError
The error type returned by
transform.Auto Trait Implementations§
impl<F> Freeze for Normalizer<F>
impl<F> RefUnwindSafe for Normalizer<F>where
F: RefUnwindSafe,
impl<F> Send for Normalizer<F>where
F: Send,
impl<F> Sync for Normalizer<F>where
F: Sync,
impl<F> Unpin for Normalizer<F>where
F: Unpin,
impl<F> UnsafeUnpin for Normalizer<F>
impl<F> UnwindSafe for Normalizer<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
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> 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>
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