mAP icon indicating copy to clipboard operation
mAP copied to clipboard

Different result compared to sklearn.metric.auc calculated

Open PaulZhangIsing opened this issue 4 years ago • 4 comments

in main.py, function, voc_ap(); I tried to add the following lines of codes there auc_ap = metrics.auc(rec, prec) print(ap, auc_ap) However, I found the result is hugely different.

PaulZhangIsing avatar Apr 02 '20 08:04 PaulZhangIsing

In python, I found that iw = bi[2] - bi[0] + 1 ih = bi[3] - bi[1] + 1 if iw > 0 and ih > 0: # compute overlap (IoU) = area of intersection / area of union ua = (bb[2] - bb[0] + 1) * (bb[3] - bb[1] + 1) + (bbgt[2] - bbgt[0] + 1) * (bbgt[3] - bbgt[1] + 1) - iw * ih ov = iw * ih / ua if ov > ovmax: ovmax = ov gt_match = obj

I wonder why the +1 in the end is necessary?

PaulZhangIsing avatar Apr 02 '20 11:04 PaulZhangIsing

In python, I found that iw = bi[2] - bi[0] + 1 ih = bi[3] - bi[1] + 1 if iw > 0 and ih > 0: # compute overlap (IoU) = area of intersection / area of union ua = (bb[2] - bb[0] + 1) * (bb[3] - bb[1] + 1) + (bbgt[2] - bbgt[0] + 1) * (bbgt[3] - bbgt[1] + 1) - iw * ih ov = iw * ih / ua if ov > ovmax: ovmax = ov gt_match = obj

I wonder why the +1 in the end is necessary?

for example, one bbox is like this

[xmin, ymin, xmax, ymax] = [3, 4, 5, 6]

so compute the witdth like this

# 3 4 5
width = 5 - 3 + 1 = 3

zjZSTU avatar Apr 21 '20 02:04 zjZSTU

in main.py, function, voc_ap(); I tried to add the following lines of codes there auc_ap = metrics.auc(rec, prec) print(ap, auc_ap) However, I found the result is hugely different.

same question

tuobameng avatar May 14 '20 10:05 tuobameng

in main.py, function, voc_ap(); I tried to add the following lines of codes there auc_ap = metrics.auc(rec, prec) print(ap, auc_ap) However, I found the result is hugely different.

same question

sklearn.metric.auc works for ROC-curve

import numpy as np
from sklearn import metrics
y = np.array([1, 1, 2, 2])
pred = np.array([0.1, 0.4, 0.35, 0.8])
fpr, tpr, thresholds = metrics.roc_curve(y, pred, pos_label=2)
metrics.auc(fpr, tpr)

refer to sklearn.metrics.auc

zjZSTU avatar May 15 '20 02:05 zjZSTU