Graphviz、pydotplus绘制梯度提升树结构图

安装

# 梯度提升树结构图
from sklearn import tree
import pydotplus 

# 绘制前十颗树,并保存为png
# clf = ensemble.GradientBoostingRegressor(**params) ,模型训练部分省略
for i in range(0,10):
    sub_tree = clf.estimators_[i, 0]

    dot_data = tree.export_graphviz(
            sub_tree,
            out_file=None, filled=True,
            rounded=True,  
            special_characters=True,
            proportion=True,
            )

    graph = pydotplus.graph_from_dot_data(dot_data)  
    graph.write_png("tree"+str(i)+".png")

Graphviz、pydotplus绘制梯度提升树结构图

相关文章:

  • 2021-05-22
  • 2021-10-01
  • 2021-08-26
  • 2022-01-19
  • 2022-12-23
  • 2021-09-22
猜你喜欢
  • 2021-12-22
  • 2021-05-27
  • 2021-12-22
  • 2021-09-22
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案