Doubt in code of normalisation confusion matrx

row_sums = conf_mx.sum(axis=1, keepdims=True)
norm_conf_mx = conf_mx / row_sums
np.fill_diagonal(norm_conf_mx, 0)
plt.matshow(norm_conf_mx, cmap=plt.cm.gray)
plt.show()
Q.Why we have taken axis=1 for row sums , is it not for column sums?
Q. what is the meaning of keepdims??

Hi Soumyadeep,

  1. Here, rows represent actual classes, while columns represent predicted classes. Hence, summing over rows ( axis=1 ) gives the correct result (e.g., 5923 for class 0).

  2. In numpy.sum() there is parameter called " keepdims "… Parameters: … keepdims : bool, optional If this is set to True , the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. Its basically an indicator that controls the dimensions of the output.

I hope it helps

Regards

can you clarify the meaning of classes

Hi Soumyadeep,

Here, as its a Multiclass Classifier the classes are from 0-9.

Regards