Skip to main content

category_metrics

Function category_metrics 

Source
pub fn category_metrics(
    labels: &[Option<usize>],
    gold: &[usize],
    n_categories: usize,
) -> Result<Vec<CategoryMetrics>, SymplexError>
Expand description

Per-category precision, recall and F₁ of a worker against gold labels, over the items the worker answered.

use symplex::stats::aggregation::category_metrics;
use symplex::linprog::q;

let m = category_metrics(&[Some(0), Some(0), Some(1), None], &[0, 1, 1, 0], 2)?;
assert_eq!((m[0].precision.clone(), m[0].recall.clone(), m[0].f1.clone()), (Some(q(1, 2)), Some(q(1, 1)), Some(q(2, 3))));

§Errors

SymplexError::InvalidArgument if the lengths differ or a label or gold value is ≥ n_categories.