Вла*_*мов 2 python machine-learning decision-tree pandas scikit-learn
我试图通过sklearn lib树绘制一棵树,但问题是列索引写在图中。
tree.plot_tree(clf_decision)
利用feature_names和class_names参数:
from sklearn.datasets import load_iris
from sklearn import tree
iris = load_iris()
clf = tree.DecisionTreeClassifier(random_state=0).fit(iris.data, iris.target)
tree.plot_tree(clf, feature_names=iris.feature_names, class_names=iris.target_names)
Run Code Online (Sandbox Code Playgroud)