Struct eval_metrics::classification::MultiConfusionMatrix
source ·
[−]pub struct MultiConfusionMatrix {
pub dim: usize,
pub counts: Vec<Vec<usize>>,
// some fields omitted
}Expand description
Confusion matrix for multi-class classification, in which rows represent predicted counts and columns represent labeled counts
Fields
dim: usizeoutput dimension
counts: Vec<Vec<usize>>count data
Implementations
Computes a new confusion matrix from the provided scores and labels
Arguments
scores- vector of class scoreslabels- vector of class labels (indexed at zero)
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::MultiConfusionMatrix;
let scores = vec![
vec![0.3, 0.1, 0.6],
vec![0.5, 0.2, 0.3],
vec![0.2, 0.7, 0.1],
vec![0.3, 0.3, 0.4],
vec![0.5, 0.1, 0.4],
vec![0.8, 0.1, 0.1],
vec![0.3, 0.5, 0.2]
];
let labels = vec![2, 1, 1, 2, 0, 2, 0];
let matrix = MultiConfusionMatrix::compute(&scores, &labels)?;Constructs a multi confusion matrix with the provided counts
Arguments
counts- vector of vector of counts, where each inner vector represents a row in the confusion matrix
Errors
An invalid input error will be returned if the counts are not a square matrix, or if the counts are all zero
Examples
use eval_metrics::classification::MultiConfusionMatrix;
let counts = vec![
vec![8, 3, 2],
vec![1, 5, 3],
vec![2, 1, 9]
];
let matrix = MultiConfusionMatrix::from_counts(counts)?;Computes precision, which necessarily requires a specified averaging method
Arguments
avg- averaging method, which can be either ‘Macro’ or ‘Weighted’
Computes recall, which necessarily requires a specified averaging method
Arguments
avg- averaging method, which can be either ‘Macro’ or ‘Weighted’
Computes F1, which necessarily requires a specified averaging method
Arguments
avg- averaging method, which can be either ‘Macro’ or ‘Weighted’
Computes Rk, also known as the multi-class Matthews correlation coefficient following the approach of Gorodkin in “Comparing two K-category assignments by a K-category correlation coefficient” (2004)
Computes per-class accuracy, resulting in a vector of values for each class
Computes per-class precision, resulting in a vector of values for each class
Computes per-class recall, resulting in a vector of values for each class
Computes per-class F1, resulting in a vector of values for each class
Trait Implementations
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
Auto Trait Implementations
impl RefUnwindSafe for MultiConfusionMatrix
impl Send for MultiConfusionMatrix
impl Sync for MultiConfusionMatrix
impl Unpin for MultiConfusionMatrix
impl UnwindSafe for MultiConfusionMatrix
Blanket Implementations
Mutably borrows from an owned value. Read more
