调整 ConfusionMatrixDisplay 的大小 (ScikitLearn) [英] Adjust size of ConfusionMatrixDisplay (ScikitLearn)

查看:205
本文介绍了调整 ConfusionMatrixDisplay 的大小 (ScikitLearn)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置 ScikitLearn 的 ConfusionMatrixDisplay 绘制的图形的大小?

How to set the size of the figure ploted by ScikitLearn's ConfusionMatrixDisplay?

import numpy as np
from sklearn.metrics import ConfusionMatrixDisplay, confusion_matrix
cm = confusion_matrix(np.arange(25), np.arange(25))
cmp = ConfusionMatrixDisplay(cm, display_labels=np.arange(25))
cmp.plot()

上面的代码就是这个图,太紧了:

The code above shows this figure, which is too tight:

推荐答案

您可以将 ax 参数发送到现有 PyPlot 图的 plot.之前设置好图形的大小即可.

You can send an ax parameter to plot of an existing PyPlot figure. Just set the size of the figure before.

import numpy as np
from sklearn.metrics import ConfusionMatrixDisplay, confusion_matrix
import matplotlib.pyplot as plt
cm = confusion_matrix(np.arange(25), np.arange(25))
cmp = ConfusionMatrixDisplay(cm, display_labels=np.arange(25))
fig, ax = plt.subplots(figsize=(10,10))
cmp.plot(ax=ax)

这篇关于调整 ConfusionMatrixDisplay 的大小 (ScikitLearn)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆