如何通过tree.plot_tree设置树视图中的列名?
How to set the name of columns in the tree view through tree.plot_tree?
我想通过sklearn lib tree画一棵树,但是问题是图中写的是列索引
tree.plot_tree(clf_decision)
利用feature_names
and class_names
parameters:
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)
我想通过sklearn lib tree画一棵树,但是问题是图中写的是列索引
tree.plot_tree(clf_decision)
利用feature_names
and class_names
parameters:
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)