热线电话:13121318867

登录
2019-07-08 阅读量: 861
如何对决策树回归的结果进行可视化展示

如何对决策树回归的结果进行可视化展示

# arange for creating a range of values

# from min value of X to max value of X

# with a difference of 0.01 between two

# consecutive values

X_grid = np.arange(min(X), max(X), 0.01)

# reshape for reshaping the data into

# a len(X_grid)*1 array, i.e. to make

# a column out of the X_grid values

X_grid = X_grid.reshape((len(X_grid), 1))

# scatter plot for original data

plt.scatter(X, y, color = 'red')

# plot predicted data

plt.plot(X_grid, regressor.predict(X_grid), color = 'blue')

# specify title

plt.title('Profit to Production Cost (Decision Tree Regression)')

# specify X axis label

plt.xlabel('Production Cost')

# specify Y axis label

plt.ylabel('Profit')

# show the plot

plt.show()

0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子