I have got following very simple python code:
from sklearn.metrics import ConfusionMatrixDisplay
# Holdout method with 2/3 training
X_train, X_test, y_train, y_test = train_test_split(self.train, self.target, test_size=0.33)
# train the k-NN
classifier = neighbors.KNeighborsClassifier(k)
classifier.fit(X_train, y_train)
# predict the test set on our trained classifier
y_test_predicted = classifier.predict(X_test)
ConfusionMatrixDisplay.from_predictions(y_test,y_test_predicted)
The thing is my predictions have several classes and the plotted matrix is just way to small to properly display the result... ( it gets automatically plotted only with this line inside a Jupyter notebook)
My question is simple. How do i increase the size of the confusion matrix using this method ?
I literally have searched dozens of sites now but its not leading anywhere.
They all seem to somehow involve matplotlib which i am just not intelligent enough to understand it seems.
I am am desperate at this point because the problem seems so simple but yet so impossible.
How do i increase the size of the plotted confusion matrix?
CodePudding user response:
You can create an ax
with the size you want (in the below example, I set it to (50,50)
and pass it to function as argument ax
) ?
f,ax = plt.subplots(1,1,figsize=(50,50))
ConfusionMatrixDisplay.from_predictions(y_test, y_pred, ax=ax)