Skip to content

lazymatrix::NormalizationChain ​

LazyMatrix for Rust · 0.9.0

Source

rust
pub struct NormalizationChain<A, B>

Two normalization recipes applied from left to right.

Chains may contain either axis, repeated axes, and further chains. Each stage is fitted on the logical output of its predecessors. Later stages can change statistics established by earlier stages.

Row stages require dense indexed access throughout the sequence:

rust
use lazymatrix::{ColumnNormalization, ColumnStats, MatrixShape, RowNormalization};
fn unsupported<M: ColumnStats<f64> + MatrixShape>(data: &M) {
    let _ = RowNormalization::standardize()
        .then(ColumnNormalization::standardize()).fit::<_, f64>(data);
}
rust
use lazymatrix::{ColumnNormalization, RowNormalization};
use ndarray::array;

let training = array![[1., 3., 2.], [7., 3., 8.], [2., 8., 5.]];
let validation = array![[100., 120., 90.]];
let recipe = RowNormalization::standardize()
    .then(ColumnNormalization::standardize());
let fitted = recipe.fit(&training).unwrap();
let train = fitted.view().apply_frozen(training.view());
let valid = fitted.view().for_new_samples(validation.view()).unwrap();
assert_eq!(valid.normalization().first().parameters().nrows(), 1);
assert_eq!(train.normalization().next(), valid.normalization().next());

Inherent implementation ​

Source

rust
impl<A, B> NormalizationChain<A, B>

first ​

rust
pub fn first(&self) -> &A

Source

Inspect the first recipe or prefix.

fit ​

rust
pub fn fit<M, F>(
    self,
    data: &M
) -> Result<<Self as Fit<M, F>>::Params, <M as MatrixErrorType>::Error> where M: MatrixShape + MatrixErrorType, F: Scalar, Self: Fit<M, F>

Source

Fit every stage without retaining the training data.

Mixed chains require dense indexed access. Column-only chains use native traversal on supported dense, sparse, and chunked backends.

Errors ​

Returns the backend error from a statistics scan.

fit_apply ​

rust
pub fn fit_apply<M, F, P>(
    self,
    data: M
) -> Result<LazyMatrix<M, P>, <M as MatrixErrorType>::Error> where M: MatrixShape + MatrixErrorType, F: Scalar, P: Stage<Scalar = F>, Self: Fit<M, F, Params = P>

Source

Fit the chain and move its fitted values into a lazy operator.

Errors ​

Returns the backend error from fitting.

next ​

rust
pub fn next(&self) -> &B

Source

Inspect the next recipe or suffix.

then ​

rust
pub fn then<R>(self, next: R) -> NormalizationChain<Self, R>

Source

Append a recipe after every stage in this chain.

Implementation of Clone ​

Source

rust
impl<A: core::clone::Clone, B: core::clone::Clone> Clone for NormalizationChain<A, B>

clone ​

rust
fn clone(&self) -> Self

Source

Implementation of Copy ​

Source

rust
impl<A: core::marker::Copy, B: core::marker::Copy> Copy for NormalizationChain<A, B>

Implementation of Debug ​

Source

rust
impl<A: core::fmt::Debug, B: core::fmt::Debug> Debug for NormalizationChain<A, B>

fmt ​

rust
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result

Source

Implementation of Eq ​

Source

rust
impl<A: core::cmp::Eq, B: core::cmp::Eq> Eq for NormalizationChain<A, B>

Implementation of FitColumns ​

Source

rust
impl<M, F, A, B> FitColumns<M, F> for lazymatrix::NormalizationChain<A, B> where M: Source<F>, F: Scalar, A: FitColumns<M, F>, B: FitColumns<M, F>, <<A as >::Params as Stage>::Kind: Combine<<<B as >::Params as Stage>::Kind>

fit_columns ​

rust
fn fit_columns<P: Stage<Scalar = F>>(
    self,
    data: &M,
    prefix: &P
) -> Result<<Self as >::Params, <M as MatrixErrorType>::Error>

Source

Implementation of FitDense ​

Source

rust
impl<M, F, A, B> FitDense<M, F> for lazymatrix::NormalizationChain<A, B> where M: MatrixRead<F> + MatrixErrorType, F: Scalar, A: FitDense<M, F>, B: FitDense<M, F>, <<A as >::Params as Stage>::Kind: super::Combine<<<B as >::Params as Stage>::Kind>

fit_dense ​

rust
fn fit_dense<P: Stage<Scalar = F>>(
    self,
    data: &M,
    prefix: &P
) -> Result<<Self as >::Params, <M as MatrixErrorType>::Error>

Source

Implementation of PartialEq ​

Source

rust
impl<A: core::cmp::PartialEq, B: core::cmp::PartialEq> PartialEq for NormalizationChain<A, B>

eq ​

rust
fn eq(&self, other: &Self) -> bool

Source

Implementation of Recipe ​

Source

rust
impl<M, A, B, P, Q> Recipe<M, NormalizationChainParams<P, Q>> for NormalizationChain<A, B> where M: MatrixShape + MatrixErrorType, P: Stage, Q: Stage<Scalar = <P as NormalizationParams>::Scalar>, <P as >::Kind: Combine<<Q as >::Kind>, Self: Fit<M, <P as NormalizationParams>::Scalar, Params = NormalizationChainParams<P, Q>>

fit ​

rust
fn fit(
    self,
    data: &M
) -> Result<NormalizationChainParams<P, Q>, <M as MatrixErrorType>::Error>

Source

Implementation of RecipeType ​

Source

rust
impl<A, B, F> RecipeType<F> for NormalizationChain<A, B> where F: Scalar, A: RecipeType<F>, B: RecipeType<F>, <<A as >::Params as Stage>::Kind: Combine<<<B as >::Params as Stage>::Kind>

Params ​

rust
type Params = NormalizationChainParams<<A as RecipeType<F>>::Params, <B as RecipeType<F>>::Params>;

Source

Implementation of StructuralPartialEq ​

Source

rust
impl<A: core::cmp::PartialEq, B: core::cmp::PartialEq> StructuralPartialEq for NormalizationChain<A, B>

Implementation of Freeze ​

rust
impl<A, B> Freeze for NormalizationChain<A, B> where A: Freeze, B: Freeze

Implementation of RefUnwindSafe ​

rust
impl<A, B> RefUnwindSafe for NormalizationChain<A, B> where A: RefUnwindSafe, B: RefUnwindSafe

Implementation of Send ​

rust
impl<A, B> Send for NormalizationChain<A, B> where A: Send, B: Send

Implementation of Sync ​

rust
impl<A, B> Sync for NormalizationChain<A, B> where A: Sync, B: Sync

Implementation of Unpin ​

rust
impl<A, B> Unpin for NormalizationChain<A, B> where A: Unpin, B: Unpin

Implementation of UnsafeUnpin ​

rust
impl<A, B> UnsafeUnpin for NormalizationChain<A, B> where A: UnsafeUnpin, B: UnsafeUnpin

Implementation of UnwindSafe ​

rust
impl<A, B> UnwindSafe for NormalizationChain<A, B> where A: UnwindSafe, B: UnwindSafe

Implementation of Any ​

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

Implementation of Boilerplate ​

rust
impl<T> Boilerplate for T where T: Copy + Send + Sync + Debug + PartialEq + 'static

Implementation of Borrow ​

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

Implementation of BorrowMut ​

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

Implementation of ByRef ​

rust
impl<T> ByRef<T> for T

Implementation of CastableFrom ​

rust
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?Sized

Implementation of CastableFrom ​

rust
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?Sized

Implementation of CloneToUninit ​

rust
impl<T> CloneToUninit for T where T: Clone

Implementation of Equivalent ​

rust
impl<Q, K> Equivalent<K> for Q where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized

Implementation of Equivalent ​

rust
impl<Q, K> Equivalent<K> for Q where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized

Implementation of Fit ​

Source

rust
impl<R, M, F> Fit<M, F> for R where M: MatrixShape + MatrixErrorType, F: Scalar, R: RecipeType<F>, <<R as RecipeType<F>>::Params as Stage>::Kind: FitKind<M, F, R>

Implementation of From ​

rust
impl<T> From<T> for T

Implementation of Imply ​

rust
impl<T, U> Imply<T> for U where T: ?Sized, U: ?Sized

Implementation of Into ​

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

Implementation of IntoEither ​

rust
impl<T> IntoEither for T

Implementation of NormalizationRecipe ​

Source

rust
impl<M, P, R> NormalizationRecipe<M, P> for R where M: MatrixErrorType, P: NormalizationParams, R: Recipe<M, P>

Implementation of Pointable ​

rust
impl<T> Pointable for T

Implementation of Read ​

rust
impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?Sized

Implementation of Same ​

rust
impl<T> Same for T

Implementation of Scalar ​

rust
impl<T> Scalar for T where T: 'static + Clone + PartialEq + Debug

Implementation of SupersetOf ​

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

Implementation of ToOwned ​

rust
impl<T> ToOwned for T where T: Clone

Implementation of TryFrom ​

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

Implementation of TryInto ​

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

Released under the MIT and Apache 2.0 licenses.