增加决策树中节点的大小

问题描述 投票:0回答:1

我正在使用决策树分类器并想使用 matplotlib 绘制树

我正在使用这个但是节点很小而且不清楚:

from sklearn import tree
import matplotlib.pyplot as plt

plt.figure(figsize=(15,15))
tree.plot_tree(model_dt_smote,filled=True)
python matplotlib scikit-learn decision-tree
1个回答
1
投票

您可以将

axe
传递给具有大
tree.plot_tree
figsize
并设置更大的
fontsize
如下所示:

(我不能运行你的代码然后我发送一个例子)

from sklearn.datasets import load_iris
import matplotlib.pyplot as plt
from sklearn import tree

clf = tree.DecisionTreeClassifier(random_state=0)
iris = load_iris()
clf = clf.fit(iris.data, iris.target)

fig, axe = plt.subplots(figsize=(20,10))
tree.plot_tree(clf, ax = axe, fontsize=15)

输出:

© www.soinside.com 2019 - 2024. All rights reserved.