pub fn fbeta_score<T>(
pred: &[T],
actual: &[T],
beta: f32,
average: Average,
) -> Result<f32, LengthError>
Expand description
The fbeta of a dataset
Returns the fbeta score [0, 1]
Supports macro and weighted averages
#[macro_use] extern crate approx; // for approximate equality check
use parsnip::{Average, fbeta_score, LengthError};
let actual = vec![0, 1, 2, 0, 1, 2];
let pred = vec![0, 2, 1, 0, 0, 1];
assert_ulps_eq!(fbeta_score(&pred, &actual, 0.5, Average::Macro)?, 0.23809524);
assert_ulps_eq!(fbeta_score(&pred, &actual, 0.5, Average::Weighted)?, 0.23809527);