I have a classifier that does binary classification. For training I take the data I trust. For testing, I take the data I trust and also some not so good data (real world data).
How do I get a confusion matrix without extra columns?
Here is my test code
import matplotlib.pyplot as plt
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
y_test = [0, 1, 1, 1, 2, 2, 3]
predictions = [0, 1, 1, 1, 0, 1, 0]
cm = confusion_matrix(y_test, predictions)
l = ["M", "F", "M?", "F?"]
disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=l)
disp.plot()
plt.show()
# I expect a 4x2 matrix here. How can I do it?
See? Unnecessary columns are here
Am I missing something?
Because you said "... my question ishow to make a 4x2 matrix." on comments I wrote this:
Here is the result:
However I feel like you want this 2x4 instead (As your question was a bit vague) :
Here is the result: