Function rusty_machine::analysis::score::precision
[−]
[src]
pub fn precision<'a, I, T>(outputs: I, targets: I) -> f64 where I: ExactSizeIterator<Item=&'a T>, T: 'a + PartialEq + Zero + One
Returns the precision score for 2 class classification.
Precision is calculated with true-positive / (true-positive + false-positive), see Precision and Recall for details.
Arguments
outputs
- Iterator of output (predicted) labels which only contains 0 or 1.targets
- Iterator of expected (actual) labels which only contains 0 or 1.
Examples
use rusty_machine::analysis::score::precision; let outputs = [1, 1, 1, 0, 0, 0]; let targets = [1, 1, 0, 0, 1, 1]; assert_eq!(precision(outputs.iter(), targets.iter()), 2.0f64 / 3.0f64);
Panics
- outputs and targets have different length
- outputs or targets contains a value which is not 0 or 1