pub fn average_precision_score_from_curve<S>(
precision: &ArrayBase<S, Ix1>,
recall: &ArrayBase<S, Ix1>,
) -> f64Expand description
Calculate the average precision score from a precision-recall curve.
The average precision score summarizes a precision-recall curve as the weighted mean of precisions achieved at each threshold, with the increase in recall from the previous threshold used as the weight.
§Arguments
precision- Precision valuesrecall- Recall values
§Returns
- The average precision score
§Examples
use scirs2_core::ndarray::array;
use scirs2_metrics::classification::threshold::{precision_recall_curve, average_precision_score_from_curve};
let y_true = array![0.0, 0.0, 1.0, 1.0];
let y_prob = array![0.1, 0.4, 0.35, 0.8];
let (precision, recall, _thresholds) = precision_recall_curve(&y_true, &y_prob, None, None).unwrap();
let average_precision = average_precision_score_from_curve(&precision, &recall);