我尝试使用 sklearn.metrics.plot_confusion_matrix 包用 Jupyter notebook 绘制混淆矩阵,但默认图形大小有点小。我在绘图之前添加了 plt.figure(figsize=(20, 20)) ,但图形大小没有随输出文本“图形大小 1440x1440 与 0 轴”而变化。如何更改图形大小?
%matplotlib inline
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.metrics import plot_confusion_matrix
from matplotlib import pyplot as plt
plt.figure(figsize=(20, 20))
clf = GradientBoostingClassifier(random_state=42)
clf.fit(X_train, y_train)
plot_confusion_matrix(clf, X_test, y_test, cmap=plt.cm.Blues)
plt.title('Confusion matrix')
plt.show()
Run Code Online (Sandbox Code Playgroud)
matplotlib python-3.x confusion-matrix scikit-learn jupyter-notebook