Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';随机回归器';对象没有属性';coef';_Python_Scikit Learn_Random Forest - Fatal编程技术网

Python 属性错误:';随机回归器';对象没有属性';coef';

Python 属性错误:';随机回归器';对象没有属性';coef';,python,scikit-learn,random-forest,Python,Scikit Learn,Random Forest,我用随机森林回归器解决了一个回归问题,现在我想画回归线,根据答案,我正在尝试这个 w=model1.coef[0] a=-w[0]/w[1] xx=np.linspace(-5,5) yy=a*xx-(模型1.截距[0])/w[1] plt.绘图(xx,yy,'k-') 其中model1是sklearn.emblem.RandomForestRegressor,它已经适合于数据集。有哪些替代方案 错误消息是 AttributeError:“RandomForestRegressionor”对象

我用随机森林回归器解决了一个回归问题,现在我想画回归线,根据答案,我正在尝试这个

w=model1.coef[0]
a=-w[0]/w[1]
xx=np.linspace(-5,5)
yy=a*xx-(模型1.截距[0])/w[1]
plt.绘图(xx,yy,'k-')
其中model1是
sklearn.emblem.RandomForestRegressor
,它已经适合于数据集。有哪些替代方案

错误消息是


AttributeError:“RandomForestRegressionor”对象没有属性“coef”

当模型适合超平面时,您将拥有
coef
intercept
。线性回归就是这样一种模型,它沿着列车数据拟合超平面,使偏差/误差最小。这些
coef
intercept
表示超平面


然而,像随机森林这样的模型并不适合超平面,而是根据最终导致预测的输入确定一组决策。您可以将它们视为一组嵌套的if-else条件。因此,如果您的模型是基于随机林的,那么就不存在
coef\uu
intercept\u
的概念,但您可以做的是打印决策树。

如果您查看。没有任何
coef
属性或
intercept
@skrrrt我们有什么办法可以得到这个吗?在我看来,你试图用拟合a后获得的参数绘制预测线,a具有
coef
intercept
是,但在拟合非线性回归模型后