Car*_*zón 3 graphviz decision-tree scikit-learn
我已经训练了一个渐变增强分类器,我想使用此处显示的graphviz_exporter工具对其进行可视化.
当我尝试它时,我得到:
AttributeError: 'GradientBoostingClassifier' object has no attribute 'tree_'
Run Code Online (Sandbox Code Playgroud)
这是因为graphviz_exporter用于决策树,但我想还有一种可视化方法,因为渐变提升分类器必须有一个基础决策树.
有谁知道怎么做?
属性估计器包含基础决策树.以下代码显示受过训练的GradientBoostingClassifier的树之一.
clf = GradientBoostingClassifier(
n_estimators=200,
learning_rate=1.0,
max_depth=3,
random_state=42
)
clf = clf.fit(X[:600], Y[:600])
# Get the tree number 42
sub_tree_42 = clf.estimators_[42, 0]
dot_data = tree.export_graphviz(
sub_tree_42,
out_file=None, filled=True,
rounded=True,
special_characters=True,
proportion=True,
)
graph = pydotplus.graph_from_dot_data(dot_data)
Image(graph.create_png())
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4609 次 |
| 最近记录: |