Skip to content

lazymatrix::NormalizationChainParams ​

LazyMatrix for Rust · 0.9.0

Source

rust
pub struct NormalizationChainParams<A, B>

Fitted stages retained in the same order and tree shape as their recipes.

Column stages contain ColumnNormalizationParams. Row stages contain FittedRowNormalization, retaining the recipe needed to prepare new samples. Application consumes owned stages or explicit borrowed views.

Chains deliberately require explicit application names:

rust
use lazymatrix::{ColumnNormalizationParams, FittedRowNormalization,
    MatrixShape, NormalizationChainParams, RowNormalizationParams};
fn ambiguous<M: MatrixShape>(
    params: NormalizationChainParams<
        FittedRowNormalization<RowNormalizationParams>, ColumnNormalizationParams>,
    data: M,
) {
    let _ = params.apply(data);
}

Mixed chains do not acquire batched products:

rust
use lazymatrix::{ColumnNormalization, MatMatInto, MatrixErrorType,
    MatrixRead, MatrixWrite, RowNormalization};
fn batched<M: MatrixRead<f64> + MatrixErrorType,
    D: MatrixRead<f64> + MatrixWrite<f64>>(data: M, rhs: &D, out: &mut D)
{
    let op = RowNormalization::standardize()
        .then(ColumnNormalization::standardize()).fit_apply(data).unwrap();
    op.matmat_into(rhs, out).unwrap();
}

Preparing new samples cannot extend borrowed column parameters' lifetime:

rust
use lazymatrix::{ColumnNormalizationParams, ColumnNormalizationParamsView,
    FittedRowNormalization, LazyMatrix, MatrixErrorType, MatrixRead,
    NormalizationChainParams, RowNormalization, RowNormalizationParams};
fn escaped<M: MatrixRead<f64> + MatrixErrorType>(data: M)
    -> LazyMatrix<M, NormalizationChainParams<
        FittedRowNormalization<RowNormalizationParams>,
        ColumnNormalizationParamsView<'static>>>
{
    let rows = FittedRowNormalization::from_parts(RowNormalization::standardize(),
        RowNormalizationParams::from_parts(data.nrows(), None, None));
    let cols = ColumnNormalizationParams::from_parts(data.ncols(), None, None);
    let params = NormalizationChainParams::from_parts(rows, cols);
    params.view().for_new_samples(data).unwrap()
}

Inherent implementation ​

Source

rust
impl<A, B> NormalizationChainParams<A, B> where A: Stage, B: Stage<Scalar = <A as NormalizationParams>::Scalar>, <A as >::Kind: Combine<<B as >::Kind>

apply_frozen ​

rust
pub fn apply_frozen<M: MatrixShape>(self, data: M) -> LazyMatrix<M, Self>

Source

Apply every saved stage unchanged to matching rows and columns.

This performs no fitting, data reads, or parameter copies.

Panics ​

Panics if any fitted axis has a different dimension from the data.

first ​

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

Source

Inspect the first fitted stage or prefix.

for_new_samples ​

rust
pub fn for_new_samples<M>(
    self,
    data: M
) -> Result<LazyMatrix<M, <Self as Stage>::NewRows>, <M as MatrixErrorType>::Error> where M: MatrixShape + MatrixErrorType, <Self as Stage>::Kind: Prepare<M, Self>

Source

Prepare new samples, refitting row stages and reusing column stages.

Row fitting occurs after the preceding prepared stages. Owned column parameters move into the result; a view lends its training columns to the result. Newly fitted row parameters are owned in both cases.

Errors ​

Returns the backend error from preparation.

Panics ​

Panics before reading data if a saved column count differs.

from_parts ​

rust
pub fn from_parts(first: A, next: B) -> Self

Source

Assemble explicit or previously fitted stages without fitting or copying.

Matrix dimensions are validated when the chain is applied.

into_parts ​

rust
pub fn into_parts(self) -> (A, B)

Source

Recover both fitted stages without copying.

next ​

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

Source

Inspect the next fitted stage or suffix.

view ​

rust
pub fn view(
    &self
) -> NormalizationChainParams<<A as >::View<'_>, <B as >::View<'_>>

Source

Borrow all saved parameter vectors without allocation or copying.

Implementation of Clone ​

Source

rust
impl<A: core::clone::Clone, B: core::clone::Clone> Clone for NormalizationChainParams<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 NormalizationChainParams<A, B>

Implementation of Debug ​

Source

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

fmt ​

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

Source

Implementation of NormalizationParams ​

Source

rust
impl<A, B> NormalizationParams for NormalizationChainParams<A, B> where A: Stage, B: Stage<Scalar = <A as NormalizationParams>::Scalar>, <A as >::Kind: Combine<<B as >::Kind>

Scalar ​

rust
type Scalar = <A as NormalizationParams>::Scalar;

Source

Implementation of Params ​

Source

rust
impl<A, B> Params for NormalizationChainParams<A, B> where A: Stage, B: Stage<Scalar = <A as NormalizationParams>::Scalar>, <A as >::Kind: Combine<<B as >::Kind>

assert_shape ​

rust
fn assert_shape(&self, nrows: usize, ncols: usize)

Source

Implementation of PartialEq ​

Source

rust
impl<A: core::cmp::PartialEq, B: core::cmp::PartialEq> PartialEq for NormalizationChainParams<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>>

Implementation of ReuseColumns ​

Source

rust
impl<A, B> ReuseColumns for NormalizationChainParams<A, B> where A: ReuseColumns<Kind = Columns>, B: ReuseColumns<Scalar = <A as NormalizationParams>::Scalar, Kind = Columns>

reuse ​

rust
fn reuse(self) -> <Self as >::NewRows

Source

Implementation of Stage ​

Source

rust
impl<A, B> Stage for NormalizationChainParams<A, B> where A: Stage, B: Stage<Scalar = <A as NormalizationParams>::Scalar>, <A as >::Kind: Combine<<B as >::Kind>

Kind ​

rust
type Kind = <<A as Stage>::Kind as Combine<<B as Stage>::Kind>>::Output;

Source

NewRows ​

rust
type NewRows = NormalizationChainParams<<A as Stage>::NewRows, <B as Stage>::NewRows>;

Source

View ​

rust
type View<'a> = NormalizationChainParams<<A as Stage>::View<'a>, <B as Stage>::View<'a>> where Self: 'a;

Source

assert_columns ​

rust
fn assert_columns(&self, ncols: usize)

Source

entry ​

rust
fn entry(
    &self,
    value: <Self as NormalizationParams>::Scalar,
    row: usize,
    column: usize
) -> <Self as NormalizationParams>::Scalar

Source

prepare_dense ​

rust
fn prepare_dense<M, P>(
    self,
    data: &M,
    prefix: &P
) -> Result<<Self as >::NewRows, <M as MatrixErrorType>::Error> where M: MatrixRead<<Self as NormalizationParams>::Scalar> + MatrixErrorType, P: Stage<Scalar = <Self as NormalizationParams>::Scalar>

Source

stage_view ​

rust
fn stage_view(&self) -> <Self as >::View<'_>

Source

Implementation of StructuralPartialEq ​

Source

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

Implementation of Freeze ​

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

Implementation of RefUnwindSafe ​

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

Implementation of Send ​

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

Implementation of Sync ​

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

Implementation of Unpin ​

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

Implementation of UnsafeUnpin ​

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

Implementation of UnwindSafe ​

rust
impl<A, B> UnwindSafe for NormalizationChainParams<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 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 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.