stark-t / PAI

Pollination_Artificial_Intelligence
5 stars 1 forks source link

YOLOv5 confusion matrix #67

Closed valentinitnelav closed 10 months ago

valentinitnelav commented 1 year ago

Hi @stark-t , I want to double check my understanding of the confusion matrix.

Let's take this confusion matrix produced by YOLOv5 (the older version used "background FN" & "background FN" notation):

image

Let's look at the category/class "Hymenoptera_Formicidae" marked above with the red rectangles. Let's assume that for the construction of this matrix, a IoU threshold IoU_thr=0.2 and a classification confidence threshold conf_thr=0.3 were used.

The values marked with an index in a circle above are:

  1. (green) True Positives, TP=0.89 This means that 89% of the cases of Hymenoptera_Formicidae (the column) are classified as / have the label Hymenoptera_Formicidae (the row) with a confidence conf > conf_thr (>0.3) and also the IoU of these predictions with the ground truth is IoU > IoU_thr (the 0.2 IoU threshold mentioned above).
  2. (red) background FP=0.49, these are False Positives defined as follows: boxes marked with the label Hymenoptera_Formicidae at conf>conf_thr, but IoU<IoU_thr.
  3. (black) background FN=0.10, are these False Negatives defined as: boxes with a conf < conf_thr and with IoU<IoU_thr and/or images with no box at all? Their ground truth label is Hymenoptera_Formicidae
  4. (yellow) False Positives=0.01 defines as: boxes with conf > conf_thr, but wrong label, and IoU > IoU_thr.
  5. (blue) this actually refers to the ground truth "Araneae" and not to Hymenoptera_Formicidae, but it is good to be aware that these are False Positives labeled as Hymenoptera_Formicidae with conf > conf_thr and IoU > IoU_thr. These would be cases 4 above if we were to look at Araneae.

Hope all of these make sense. It is a bit head scratching though :)