机器学习入门-决策树的可视化展示
Posted my-love-is-python
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了机器学习入门-决策树的可视化展示相关的知识,希望对你有一定的参考价值。
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())
以上是关于机器学习入门-决策树的可视化展示的主要内容,如果未能解决你的问题,请参考以下文章