lazymatrix::PrepareNewSamples
LazyMatrix for Rust · 0.12.0
pub trait PrepareNewSamples<M>: NormalizationParams + private::NewSamples<M> + Sized where M: MatrixShape + MatrixErrorTypeFitted 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:
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
type Params: NormalizationParams<Scalar = <Self as NormalizationParams>::Scalar>;Parameters retained or fitted for the new samples.
Methods
for_new_samples
fn for_new_samples(
self,
data: M
) -> Result<LazyMatrix<M, <Self as PrepareNewSamples>::Params>, <M as MatrixErrorType>::Error>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
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
impl<M, F, S> PrepareNewSamples<M> for lazymatrix::ColumnNormalizationParams<F, S> where M: MatrixShape + MatrixErrorType, F: Scalar, S: AsRef<[F]>
