首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AttributeError:“”RandomForestRegressor“”对象没有属性“”estimators“”

AttributeError:“”RandomForestRegressor“”对象没有属性“”estimators“”
EN

Stack Overflow用户
提问于 2021-05-15 05:42:05
回答 1查看 118关注 0票数 0

当启动这个jupyter代码时,我收到了这个代码,

代码语言:javascript
复制
AttributeError                            Traceback (most recent call last)
<ipython-input-17-d90e432a5dde> in <module>
      2 from sklearn import tree
      3 plt.figure(figsize=(40,40))
----> 4 tree.plot_tree(regressor.estimators[0],feature_names=X_train.columns, filled=True)

AttributeError: 'RandomForestRegressor' object has no attribute 'estimators'

<Figure size 2880x2880 with 0 Axes>

这就是导致问题的线路,

代码语言:javascript
复制
   "source": [
    "#validation of the algorithm\n",
    "from sklearn import tree\n",
    "plt.figure(figsize=(40,40))\n",
    "tree.plot_tree(regressor.estimators[0],feature_names=X_train.columns, filled=True)"
   ]

有任何帮助和感谢吗?

EN

回答 1

Stack Overflow用户

发布于 2021-05-15 05:45:34

正确,它不包含属性estimators。它确实包含estimators_,因此您可以尝试:

代码语言:javascript
复制
   "source": [
    "#validation of the algorithm\n",
    "from sklearn import tree\n",
    "plt.figure(figsize=(40,40))\n",
    "tree.plot_tree(regressor.estimators_[0],feature_names=X_train.columns, filled=True)"
   ]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67541238

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档