pub trait IncrementalClassifier {
// Required methods
fn fit(&mut self, examples: &[TrainingExample]);
fn partial_fit(&mut self, examples: &[TrainingExample]);
fn predict(&self, features: &[f32]) -> Option<u32>;
fn predict_proba(&self, features: &[f32]) -> Vec<f32>;
fn num_classes(&self) -> usize;
fn num_features(&self) -> usize;
fn samples_seen(&self) -> u64;
}Expand description
Common surface every classifier exposes.
Required Methods§
Sourcefn fit(&mut self, examples: &[TrainingExample])
fn fit(&mut self, examples: &[TrainingExample])
Train from scratch. Any previous weights are discarded.
Sourcefn partial_fit(&mut self, examples: &[TrainingExample])
fn partial_fit(&mut self, examples: &[TrainingExample])
Incrementally update with a mini-batch. Previous weights are preserved; this is the online-learning entrypoint.
Sourcefn predict(&self, features: &[f32]) -> Option<u32>
fn predict(&self, features: &[f32]) -> Option<u32>
Predict the most likely class for one example.
Sourcefn predict_proba(&self, features: &[f32]) -> Vec<f32>
fn predict_proba(&self, features: &[f32]) -> Vec<f32>
Predict a probability per class (0..num_classes).
Sourcefn num_classes(&self) -> usize
fn num_classes(&self) -> usize
Number of distinct classes seen so far.
Sourcefn num_features(&self) -> usize
fn num_features(&self) -> usize
Number of features the model expects. 0 until fit/
partial_fit has been called with at least one example.
Sourcefn samples_seen(&self) -> u64
fn samples_seen(&self) -> u64
Total number of training examples the model has seen over
its lifetime — incremented by both fit (reset to N) and
partial_fit (additive). Useful for lineage + rate-limiting.