# mmcls.core.average_precision¶

mmcls.core.average_precision(pred, target)[源代码]

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.

• pred (np.ndarray) – The model prediction with shape (N, ).

• target (np.ndarray) – The target of each prediction with shape (N, ).

a single float as average precision value.

float