Skip to main content

ClassifierScore

Trait ClassifierScore 

Source
pub trait ClassifierScore<F: Float> {
    // Required method
    fn score(
        &self,
        x: &Array2<F>,
        y: &Array1<usize>,
        sample_weight: Option<&Array1<F>>,
    ) -> Result<F, FerroError>;
}
Expand description

Mean-accuracy score(x, y) exposed on every fitted classifier in this crate via a blanket impl over Predict<Array2<F>, Output=Array1<usize>>.

Users just use ferrolearn_linear::ClassifierScore; to call fitted.score(&x, &y) and get the same result as sklearn’s ClassifierMixin.score.

Required Methods§

Source

fn score( &self, x: &Array2<F>, y: &Array1<usize>, sample_weight: Option<&Array1<F>>, ) -> Result<F, FerroError>

(Optionally weighted) mean accuracy on the given test data and labels.

Mirrors sklearn ClassifierMixin.score(self, X, y, sample_weight=None) (base.py:738) → accuracy_score(y, predict(X), sample_weight=...). Passing None for sample_weight reproduces the unweighted correct / n accuracy.

§Errors

Returns FerroError::ShapeMismatch if x.nrows() != y.len(), or if a non-None sample_weight has a length other than y.len(), or any error forwarded from the inner predict.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T, F> ClassifierScore<F> for T
where T: Predict<Array2<F>, Output = Array1<usize>, Error = FerroError>, F: Float,