在 plot_tree() 函数中隐藏标准名称

Hide name of criterion in plot_tree() function

我需要 plot_tree() 函数中的图表在树的每个节点中显示而没有标准值。也就是我想得到这样一张图片:

如果不使用画图 :) 我该怎么做?

我还需要把'value'这个词替换成'proba'这个词,是不是只能通过更改代码源来实现?

您可以使用 impurity=False 参数来完成此操作。这是一段可重现的代码 -

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

#load data
iris = load_iris()

#model training
clf = tree.DecisionTreeClassifier(random_state=0)
clf.fit(iris.data, iris.target)

#plotting
fig = plt.figure(figsize=(10,10))
tree.plot_tree(clf, filled=True, impurity=False)  #<-----------
plt.show()