Function parsnip::f1_score[][src]

pub fn f1_score(pred: &[u64], actual: &[u64], average: Option<String>) -> f32

The f1 score of a dataset

Returns an f1 score where 1 is perfect and 0 is atrocious.

Supports macro and weighted averages

use parsnip::f1_score;
 
let actual = vec![0, 1, 2, 0, 1, 2];
let pred = vec![0, 2, 1, 0, 0, 1];
 
assert_eq!(f1_score(&pred, &actual, Some("macro".to_string())), 0.26666665);
assert_eq!(f1_score(&pred, &actual, Some("weighted".to_string())), 0.26666668);