0
$\begingroup$

For a multiclass classification problem, How do you compute per class IOU ?

I am using the formula which is referenced/accepted in the below link

true positive / (true positive + false positive + false negative)

https://stackoverflow.com/questions/31653576/how-to-calculate-the-mean-iu-score-in-image-segmentation

If my predictions and ground truths are

y_pred = [0, 2, 0, 2]

y_true = [0, 1, 2, 2]

My confusion matrix looks like

enter image description here

Now,

per class IOU would be.

For class'0' : 1/(1+1) = 0.5
For class'1' : 0/(1) = 0
For class'2' : 1/(1+1+1) =0.33
So, mean IOU becomes : (.5+0+.33)/3 = 0.27 . Is this correct?

on the other hand Jaccard would be

y_pred = [0, 2, 1, 2]
y_true = [0, 1, 2, 2]
jaccard_score(y_true, y_pred, average=None)
array([1. , 0. , 0.33...])

This is from documentation https://scikit-learn.org/stable/modules/generated/sklearn.metrics.jaccard_score.html#sklearn.metrics.jaccard_score

$\endgroup$
1
  • $\begingroup$ Both would be the same. In your example, the second y_pred is different from first the one. $\endgroup$ – anilsathyan7 Apr 7 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.