可视化决策树

时间:2020-02-12 12:30:01

标签: python

在拟合模型后,我试图可视化我的决策树。我正在使用Kaggle上的泰坦尼克号数据集。

clf=gd.best_estimator_
clf.fit(X,y)

# Let's extract a single tree
estimator=clf.estimators_[5]

from sklearn.tree import export_graphviz

dot_data=export_graphviz(estimator,out_file=None,feature_names=df.drop("Survived",1).columns,)

如何获取数据集的目标值?

我正在使用https://chrisalbon.com/machine_learning/trees_and_forests/visualize_a_decision_tree/作为教程,但是target_names在处理泰坦尼克号数据集上不起作用。

0 个答案:

没有答案