Skip to main content

SparseClassifier

Trait SparseClassifier 

Source
pub trait SparseClassifier {
    // Required methods
    fn samples_seen(&self) -> u64;
    fn predict_proba(&self, features: &SparseFeatures) -> Result<f64, RillError>;
    fn learn(
        &mut self,
        features: &SparseFeatures,
        target: bool,
    ) -> Result<(), RillError>;
    fn reset(&mut self);

    // Provided method
    fn predict(&self, features: &SparseFeatures) -> Result<bool, RillError> { ... }
}
Expand description

An online binary classifier that accepts sparse features.

predict (and predict_proba) must be side-effect free.

Required Methods§

Source

fn samples_seen(&self) -> u64

How many training samples the model has seen so far.

Source

fn predict_proba(&self, features: &SparseFeatures) -> Result<f64, RillError>

Predict the probability of the positive class.

Source

fn learn( &mut self, features: &SparseFeatures, target: bool, ) -> Result<(), RillError>

Update the model using a single labeled sparse sample.

Source

fn reset(&mut self)

Reset the model to its initial state.

Provided Methods§

Source

fn predict(&self, features: &SparseFeatures) -> Result<bool, RillError>

Predict the boolean class label using a 0.5 threshold.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§