Skip to content

lazymatrix::PrepareNewSamples ​

LazyMatrix for Rust · 0.12.0

Source

rust
pub trait PrepareNewSamples<M>: NormalizationParams + private::NewSamples<M> + Sized where M: MatrixShape + MatrixErrorType

Fitted column parameters or chains that can prepare new samples.

Column parameters are reused unchanged. Chains reuse their column stages and refit each row stage after its prepared predecessors. This trait is sealed; downstream code can use it as a bound without depending on the execution dispatch of a particular chain.

Bare row parameters describe particular rows and do not retain a recipe:

rust
use lazymatrix::{MatrixErrorType, MatrixShape, PrepareNewSamples,
    RowNormalizationParams};
fn prepare<M: MatrixShape + MatrixErrorType>(params: RowNormalizationParams, data: M) {
    let _ = PrepareNewSamples::for_new_samples(params, data);
}

Associated types ​

Params ​

rust
type Params: NormalizationParams<Scalar = <Self as NormalizationParams>::Scalar>;

Source

Parameters retained or fitted for the new samples.

Methods ​

for_new_samples ​

rust
fn for_new_samples(
    self,
    data: M
) -> Result<LazyMatrix<M, <Self as PrepareNewSamples>::Params>, <M as MatrixErrorType>::Error>

Source

Prepare samples, preserving column parameters and refitting row stages.

Owned columns move into the result; borrowed columns retain their original lifetime. Newly fitted row vectors are owned.

Errors ​

Returns the backend error from fitting a row stage.

Panics ​

Panics before reading data if a saved column count differs.

Implementation of PrepareNewSamples ​

Source

rust
impl<M, A, B> PrepareNewSamples<M> for NormalizationChainParams<A, B> where M: MatrixShape + MatrixErrorType, Self: Stage, <Self as Stage>::Kind: Prepare<M, Self>

Implementation of PrepareNewSamples ​

Source

rust
impl<M, F, S> PrepareNewSamples<M> for lazymatrix::ColumnNormalizationParams<F, S> where M: MatrixShape + MatrixErrorType, F: Scalar, S: AsRef<[F]>

Released under the MIT and Apache 2.0 licenses.