首页 > 其他 > 详细

机器学习入门-决策树的可视化展示

时间:2019-01-17 10:02:07      阅读:360      评论:0      收藏:0      [点我收藏+]
from sklearn import tree
from sklearn.datasets.california_housing import fetch_california_housing
housing = fetch_california_housing()


dtr = tree.DecisionTreeRegressor(max_depth=2)
dtr.fit(housing.data[:, [6, 7]], housing.target)

dot_data =           tree.export_graphviz(
              dtr, 
              out_file = None, 
              feature_names=housing.feature_name[6:8],
              filled = True, 
              impurity = False,
              rounded = True
          )

import pydotplus
graph = pydotplus.graph_from_dot_data(dot_data)
graph.get_nodes()[7].set_fillcolor(#FFF2DD)
from IPython.display import Image 
Image(graph.create_png())

技术分享图片

机器学习入门-决策树的可视化展示

原文:https://www.cnblogs.com/my-love-is-python/p/10280558.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!