pub trait StreamingPreprocessor: Send + Sync {
// Required methods
fn update_and_transform(&mut self, features: &[f64]) -> Vec<f64>;
fn transform(&self, features: &[f64]) -> Vec<f64>;
fn output_dim(&self) -> Option<usize>;
fn reset(&mut self);
}Expand description
Object-safe trait for streaming feature transformers.
A StreamingPreprocessor maintains running statistics that are updated
during training and applied (without update) during prediction. This
separation ensures test-time transforms use frozen statistics.
§Object Safety
All methods use &self / &mut self with concrete return types,
allowing Box<dyn StreamingPreprocessor> for runtime-polymorphic pipelines.
§Implementors
IncrementalNormalizer— Welford online standardization (zero-mean, unit-variance).
Required Methods§
Sourcefn update_and_transform(&mut self, features: &[f64]) -> Vec<f64>
fn update_and_transform(&mut self, features: &[f64]) -> Vec<f64>
Update internal statistics from this sample and return transformed features.
Called during training. The preprocessor incorporates the sample into its running statistics (e.g., mean/variance) and returns the transformed features for the next pipeline stage.
Sourcefn transform(&self, features: &[f64]) -> Vec<f64>
fn transform(&self, features: &[f64]) -> Vec<f64>
Transform features using current statistics without updating them.
Called during prediction. Statistics remain frozen so that test-time behaviour is deterministic with respect to the training data seen so far.
Sourcefn output_dim(&self) -> Option<usize>
fn output_dim(&self) -> Option<usize>
Number of output features, or None if unknown until the first sample.