mmcls.core.average_precision¶
- mmcls.core.average_precision(pred, target)[source]¶
Calculate the average precision for a single class.
AP summarizes a precision-recall curve as the weighted mean of maximum precisions obtained for any r’>r, where r is the recall:
\[\text{AP} = \sum_n (R_n - R_{n-1}) P_n\]Note that no approximation is involved since the curve is piecewise constant.
- Parameters
pred (np.ndarray) – The model prediction with shape (N, ).
target (np.ndarray) – The target of each prediction with shape (N, ).
- Returns
a single float as average precision value.
- Return type