Classifier

Trait Classifier 

Source
pub trait Classifier {
    // Required methods
    fn train(
        &mut self,
        x_train: &Array2<f64>,
        y_train: &Array1<f64>,
    ) -> Result<()>;
    fn predict(&self, x: &Array1<f64>) -> Result<usize>;
    fn predict_proba(&self, x: &Array1<f64>) -> Result<Array1<f64>>;
    fn evaluate(
        &self,
        x_test: &Array2<f64>,
        y_test: &Array1<f64>,
    ) -> Result<ClassificationMetrics>;

    // Provided method
    fn predict_batch(&self, x: &Array2<f64>) -> Result<Array1<usize>> { ... }
}
Expand description

Trait for classification models

Required Methods§

Source

fn train(&mut self, x_train: &Array2<f64>, y_train: &Array1<f64>) -> Result<()>

Trains the classifier on a dataset

Source

fn predict(&self, x: &Array1<f64>) -> Result<usize>

Predicts the class for a sample

Source

fn predict_proba(&self, x: &Array1<f64>) -> Result<Array1<f64>>

Computes prediction probabilities for a sample

Source

fn evaluate( &self, x_test: &Array2<f64>, y_test: &Array1<f64>, ) -> Result<ClassificationMetrics>

Evaluates the classifier on a dataset

Provided Methods§

Source

fn predict_batch(&self, x: &Array2<f64>) -> Result<Array1<usize>>

Predicts classes for a batch of samples

Implementors§