Solved – Accuracy computation with clustering in 3×3 matrix

accuracyclusteringconfusion matrix

I have three true class, A, B, C in my dataset. and I got 3 clusters (0, 1, 2) from the clustering algorithm. They are not supposed to belong to the same class.
For E.g. cluster 1 can belong to class C and cluster 2 can class A. I have the following confusion matrix. How should I calculate the accuracy here where it is not obvious, which class belongs to which cluster? Please help.

  0   1    2 
A 64  0   36
B 0   92   8
c 0  100   0

Best Answer

The cluster (0,1,2) to label (A,B,C) mapping will be based on the one that maximizes your overall accuracy. In the case of the given confusion matrix the ideal mapping will be 0 --> A, 1 --> C, 2 --> B. So the confusion matrix will look like

  0      1       2
A 64     0      36
C 0      100    0
B 0      92     8

It is trivial to observe from your confusion matrix that your clustering algorithm is unable to properly distinguish between points of label B and C.

The overall accuracy is the sum of diagonals divided by the sum of all the values: $ 172/300 = 57.33 $ .

Related Question