pub struct BinaryConfusionMatrix {
    pub tp_count: usize,
    pub fp_count: usize,
    pub tn_count: usize,
    pub fn_count: usize,
    /* private fields */
}
Expand description

Confusion matrix for binary classification

Fields

tp_count: usize

true positive count

fp_count: usize

false positive count

tn_count: usize

true negative count

fn_count: usize

false negative count

Implementations

Computes a new binary confusion matrix from the provided scores and labels

Arguments
  • scores - vector of scores
  • labels - vector of boolean labels
  • threshold - decision threshold value for classifying scores
Errors

An invalid input error will be returned if either scores or labels are empty, or if their lengths do not match. An undefined metric error will be returned if scores contain any value that is not finite.

Examples
use eval_metrics::classification::BinaryConfusionMatrix;
let scores = vec![0.4, 0.7, 0.1, 0.3, 0.9];
let labels = vec![false, true, false, true, true];
let matrix = BinaryConfusionMatrix::compute(&scores, &labels, 0.5)?;

Constructs a binary confusion matrix with the provided counts

Arguments
  • tp_count - true positive count
  • fp_count - false positive count
  • tn_count - true negative count
  • fn_count - false negative count
Errors

An invalid input error will be returned if all provided counts are zero

Computes accuracy

Computes precision

Computes recall

Computes F1

Computes Matthews correlation coefficient (phi)

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.