Note

You are reading the documentation for MMClassification 0.x, which will soon be deprecated at the end of 2022. We recommend you upgrade to MMClassification 1.0 to enjoy fruitful new features and better performance brought by OpenMMLab 2.0. Check the installation tutorial, migration tutorial and changelog for more details.

# mmcls.core.precision¶

mmcls.core.precision(pred, target, average_mode='macro', thrs=0.0)[source]

Calculate precision according to the prediction and target.

Parameters
• pred (torch.Tensor | np.array) – The model prediction with shape (N, C).

• target (torch.Tensor | np.array) – The target of each prediction with shape (N, 1) or (N,).

• average_mode (str) – The type of averaging performed on the result. Options are ‘macro’ and ‘none’. If ‘none’, the scores for each class are returned. If ‘macro’, calculate metrics for each class, and find their unweighted mean. Defaults to ‘macro’.

• thrs (Number | tuple[Number], optional) – Predictions with scores under the thresholds are considered negative. Default to 0.

Returns

Precision.

Return type

float | np.array | list[float | np.array]

Args

thrs is number

thrs is tuple

average_mode = “macro”

float

list[float]

average_mode = “none”

np.array

list[np.array]