Function rusty_machine::analysis::score::f1 [] [src]

pub fn f1<'a, I, T>(outputs: I, targets: I) -> f64 where I: ExactSizeIterator<Item=&'a T>, T: 'a + PartialEq + Zero + One

Returns the f1 score for 2 class classification.

F1-score is calculated with 2 * precision * recall / (precision + recall), see F1 score for details.

Arguments

Examples

use rusty_machine::analysis::score::f1;
let outputs = [1, 1, 1, 0, 0, 0];
let targets = [1, 1, 0, 0, 1, 1];

assert_eq!(f1(outputs.iter(), targets.iter()), 0.5714285714285714);

Panics