Skip to main content

IncrementalClassifier

Trait IncrementalClassifier 

Source
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§

Source

fn fit(&mut self, examples: &[TrainingExample])

Train from scratch. Any previous weights are discarded.

Source

fn partial_fit(&mut self, examples: &[TrainingExample])

Incrementally update with a mini-batch. Previous weights are preserved; this is the online-learning entrypoint.

Source

fn predict(&self, features: &[f32]) -> Option<u32>

Predict the most likely class for one example.

Source

fn predict_proba(&self, features: &[f32]) -> Vec<f32>

Predict a probability per class (0..num_classes).

Source

fn num_classes(&self) -> usize

Number of distinct classes seen so far.

Source

fn num_features(&self) -> usize

Number of features the model expects. 0 until fit/ partial_fit has been called with at least one example.

Source

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.

Implementors§