Skip to main content

NormalizationTransform

Enum NormalizationTransform 

Source
pub enum NormalizationTransform<T: Value> {
    Domain {
        min: T,
        max: T,
    },
    Clip {
        min: T,
        max: T,
    },
    MeanSubtraction,
    ZScore,
    LogOffset {
        asymptote_epsilon: Option<T>,
    },
}
Available on crate feature transforms only.
Expand description

Transformations around normalization or otherwise controlling range

Variants§

§

Domain

Normalizes the dataset to a specified range.

Each element is linearly scaled to fit within [min, max]. Useful for mapping values to a standard range before further processing or ML workflows.

Domain example

Technical Details

xₙ = (x - x_min) / (x_max - x_min) * (max - min) + min
where
  x_min and x_max are the minimum and maximum of the original dataset.

§Parameters

  • min: Minimum value of the target range.
  • max: Maximum value of the target range.

Fields

§min: T

Minimum value of the target range

§max: T

Maximum value of the target range

§

Clip

Restricts all values in the dataset to a specified range.

Any element smaller than min is set to min, and any element larger than max is set to max. Useful for bounding outliers or enforcing hard limits.

Clip example

Technical Details

Element-wise operation:

xₙ = min(max(x, min), max)
where
  min and max are the specified bounds.

§Parameters

  • min: Lower bound of the allowed range.
  • max: Upper bound of the allowed range.

Fields

§min: T

Lower bound of the allowed range

§max: T

Upper bound of the allowed range

§

MeanSubtraction

Centers the dataset by subtracting its mean from every element.

After this transformation, the dataset has a mean of zero, but its variance and overall shape remain unchanged. Useful as a preprocessing step in statistics and machine learning.

Mean subtraction example

Technical Details

xₙ = x - mean(x)
§

ZScore

Normalizes the dataset to zero mean and unit variance.

Each element is centered by subtracting the dataset mean, then scaled by dividing with the standard deviation. This is a common preprocessing step in statistics and machine learning to make features comparable.

Z-Score example

Technical Details

Element-wise operation:

xₙ = (x - mean(x)) / std(x)
where
  mean(x) is the average of the dataset
  std(x) is the standard deviation of the dataset
§

LogOffset

Normalizes the dataset by applying a logarithmic transformation with an offset.

An asymptote - or in other words a value that the data approaches but never reaches - can cause problems for polynomial fitting. This transform tries to approximate that value, then applies a log transform to the data relative to that value

Log example

Technical Details

asymptote_epsilon = mean(Y) * 1e-02
asymptote = max(Y) + asymptote_epsilon
yₙ = ln(asymptote - y)

where
  Y is the dataset being transformed
  mean(Y) is the average of the dataset
  max(Y) is the maximum value in the dataset
  asymptote_epsilon is a small buffer added to ensure all points are below the asymptote, which is important for the log transformation

Fields

§asymptote_epsilon: Option<T>

A small epsilon added to the estimated asymptote to ensure all points are below it, which is important for the log transformation. If None, a default value of 1% of the standard deviation of the data will be used.

Trait Implementations§

Source§

impl<T: Value> Transform<T> for NormalizationTransform<T>

Source§

fn apply<'a>(&self, data: impl Iterator<Item = &'a mut T>)

Applies the transformation to the given data.
Source§

fn apply_to(&self, point: &mut T)

Applies the transformation to a single data point.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V