lazymatrix::NormalizationChain
LazyMatrix for Rust · 0.9.0
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:
use lazymatrix::{ColumnNormalization, ColumnStats, MatrixShape, RowNormalization};
fn unsupported<M: ColumnStats<f64> + MatrixShape>(data: &M) {
let _ = RowNormalization::standardize()
.then(ColumnNormalization::standardize()).fit::<_, f64>(data);
}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
impl<A, B> NormalizationChain<A, B>first
pub fn first(&self) -> &AInspect the first recipe or prefix.
fit
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>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
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>Fit the chain and move its fitted values into a lazy operator.
Errors
Returns the backend error from fitting.
next
pub fn next(&self) -> &BInspect the next recipe or suffix.
then
pub fn then<R>(self, next: R) -> NormalizationChain<Self, R>Append a recipe after every stage in this chain.
Implementation of Clone
impl<A: core::clone::Clone, B: core::clone::Clone> Clone for NormalizationChain<A, B>clone
fn clone(&self) -> SelfImplementation of Copy
impl<A: core::marker::Copy, B: core::marker::Copy> Copy for NormalizationChain<A, B>Implementation of Debug
impl<A: core::fmt::Debug, B: core::fmt::Debug> Debug for NormalizationChain<A, B>fmt
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::ResultImplementation of Eq
impl<A: core::cmp::Eq, B: core::cmp::Eq> Eq for NormalizationChain<A, B>Implementation of FitColumns
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
fn fit_columns<P: Stage<Scalar = F>>(
self,
data: &M,
prefix: &P
) -> Result<<Self as >::Params, <M as MatrixErrorType>::Error>Implementation of FitDense
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
fn fit_dense<P: Stage<Scalar = F>>(
self,
data: &M,
prefix: &P
) -> Result<<Self as >::Params, <M as MatrixErrorType>::Error>Implementation of PartialEq
impl<A: core::cmp::PartialEq, B: core::cmp::PartialEq> PartialEq for NormalizationChain<A, B>eq
fn eq(&self, other: &Self) -> boolImplementation of Recipe
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
fn fit(
self,
data: &M
) -> Result<NormalizationChainParams<P, Q>, <M as MatrixErrorType>::Error>Implementation of RecipeType
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
type Params = NormalizationChainParams<<A as RecipeType<F>>::Params, <B as RecipeType<F>>::Params>;Implementation of StructuralPartialEq
impl<A: core::cmp::PartialEq, B: core::cmp::PartialEq> StructuralPartialEq for NormalizationChain<A, B>Implementation of Freeze
impl<A, B> Freeze for NormalizationChain<A, B> where A: Freeze, B: FreezeImplementation of RefUnwindSafe
impl<A, B> RefUnwindSafe for NormalizationChain<A, B> where A: RefUnwindSafe, B: RefUnwindSafeImplementation of Send
impl<A, B> Send for NormalizationChain<A, B> where A: Send, B: SendImplementation of Sync
impl<A, B> Sync for NormalizationChain<A, B> where A: Sync, B: SyncImplementation of Unpin
impl<A, B> Unpin for NormalizationChain<A, B> where A: Unpin, B: UnpinImplementation of UnsafeUnpin
impl<A, B> UnsafeUnpin for NormalizationChain<A, B> where A: UnsafeUnpin, B: UnsafeUnpinImplementation of UnwindSafe
impl<A, B> UnwindSafe for NormalizationChain<A, B> where A: UnwindSafe, B: UnwindSafeImplementation of Any
impl<T> Any for T where T: 'static + ?SizedImplementation of Boilerplate
impl<T> Boilerplate for T where T: Copy + Send + Sync + Debug + PartialEq + 'staticImplementation of Borrow
impl<T> Borrow<T> for T where T: ?SizedImplementation of BorrowMut
impl<T> BorrowMut<T> for T where T: ?SizedImplementation of ByRef
impl<T> ByRef<T> for TImplementation of CastableFrom
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?SizedImplementation of CastableFrom
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?SizedImplementation of CloneToUninit
impl<T> CloneToUninit for T where T: CloneImplementation of Equivalent
impl<Q, K> Equivalent<K> for Q where Q: Eq + ?Sized, K: Borrow<Q> + ?SizedImplementation of Equivalent
impl<Q, K> Equivalent<K> for Q where Q: Eq + ?Sized, K: Borrow<Q> + ?SizedImplementation of Fit
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
impl<T> From<T> for TImplementation of Imply
impl<T, U> Imply<T> for U where T: ?Sized, U: ?SizedImplementation of Into
impl<T, U> Into<U> for T where U: From<T>Implementation of IntoEither
impl<T> IntoEither for TImplementation of NormalizationRecipe
impl<M, P, R> NormalizationRecipe<M, P> for R where M: MatrixErrorType, P: NormalizationParams, R: Recipe<M, P>Implementation of Pointable
impl<T> Pointable for TImplementation of Read
impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?SizedImplementation of Same
impl<T> Same for TImplementation of Scalar
impl<T> Scalar for T where T: 'static + Clone + PartialEq + DebugImplementation of SupersetOf
impl<SS, SP> SupersetOf<SS> for SP where SS: SubsetOf<SP>Implementation of ToOwned
impl<T> ToOwned for T where T: CloneImplementation of TryFrom
impl<T, U> TryFrom<U> for T where U: Into<T>Implementation of TryInto
impl<T, U> TryInto<U> for T where U: TryFrom<T>
