Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhance] Imporve efficiency of precision, recall, f1_score and support. #595

Merged
merged 4 commits into from
Dec 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix bug
mzr1996 committed Dec 10, 2021
commit ff1716e6bab83b0a7f71b611886977e5e000f02d
4 changes: 2 additions & 2 deletions mmcls/core/evaluation/eval_metrics.py
Original file line number Diff line number Diff line change
@@ -110,8 +110,8 @@ class are returned. If 'macro', calculate metrics for each class,
if thr is not None:
pred_positive[pred_score <= thr] = 0
class_correct = (pred_positive & gt_positive).sum(0)
precision = class_correct / np.maximum(pred_positive.sum(0), 1) * 100
recall = class_correct / np.maximum(gt_positive.sum(0), 1) * 100
precision = class_correct / np.maximum(pred_positive.sum(0), 1.) * 100
recall = class_correct / np.maximum(gt_positive.sum(0), 1.) * 100
f1_score = 2 * precision * recall / np.maximum(
precision + recall,
torch.finfo(torch.float32).eps)