【发布时间】:2020-12-20 18:22:08
【问题描述】:
我已经使用随机森林回归器来解决回归问题,现在我想绘制回归线,根据this 的答案,我正在尝试这个。
w = model1.coef_[0]
a = -w[0] / w[1]
xx = np.linspace(-5, 5)
yy = a * xx - (model1.intercept_[0]) / w[1]
plt.plot(xx, yy, 'k-')
其中 model1 是 sklearn.ensemble.RandomForestRegressor,它已经适合数据集。有哪些替代方案。
错误信息是
AttributeError: 'RandomForestRegressor' object has no attribute 'coef_'
【问题讨论】:
-
如果您查看sklearn.ensemble.RandomForestRegressor 的文档。没有任何
coef_属性或intercept_ -
@skrrrt 有什么办法可以得到这个吗?
-
在我看来,您正在尝试使用拟合具有
coef_和intercept_的 linear regression model 后获得的参数绘制预测线 -
是的,但在拟合 RandomForestRegressor 后不是线性回归模型
标签: python scikit-learn random-forest