I am using scikit learns decision tree to classify a set of data into one of four categories. I am new to machine learning and coding in general, and am trying to understand the confusion matrix.
So when I use sci-kits confusion matrix I get a four by four matrix. I was able to figure out that the columns are the predictions made for each category (for example 'Predicted A, Predicted B...'). However, I am confused as to what the rows represent. Also, is it possible for certain predictions to not make it onto the confusion matrix. I find that some columns don't have the necessary number of total counts. Why is this?
unique, counts = np.unique(classif_predict, return_counts=True)
print('Predicted:',dict(zip(unique, counts)))
_unique, _counts = np.unique(classif_test, return_counts=True)
print('Tested:',dict(zip(_unique, _counts)))
pd.DataFrame(
confusion_matrix(classif_test, class_predict),
columns = ['AGN Predicted', 'BeXRB Predicted', 'HMXB Predicted', 'SNR Predicted']
)
My output looks like this:
Predicted: {'AGN': 7, 'BeXRB': 25, 'HMXB': 7, 'SNR': 2}
Tested: {'AGN': 10, 'BeXRB': 22, 'HMXB': 7, 'SNR': 2}
AGN Predicted BeXRB Predicted HMXB Predicted SNR Predicted
3 3 4 0
2 13 6 1
0 3 4 0
0 2 0 0
ā```
