本文主要是介绍(DecisionTreeRegressor)决策树回归实例-加州房价数据 学习笔记,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.dataset.california_housing import fetch_california_housing
# 读取加州房价数据
housing = fetch_california_housing()
#print(housing.DESCR)
#housing.data.shape
#housing.data[0]# 决策树建模
from sklearn import tree
dtr = tree.DecisionTreeRegressor(max_depth = 2)
dtr.fit(housing.data, housing.target)# 可视化显示
dot_data = tree.export_graphviz(dtr, out_file=None, feature_names=housing.feature_names, filled=True, impurity=False, rounded=True)import pydotplus
graph = pydotplus.graph_from_dot_data(dot_data)
graph
这篇关于(DecisionTreeRegressor)决策树回归实例-加州房价数据 学习笔记的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!