当启动这个jupyter代码时,我收到了这个代码,
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>这就是导致问题的线路,
"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)"
]有任何帮助和感谢吗?
发布于 2021-05-15 05:45:34
正确,它不包含属性estimators。它确实包含estimators_,因此您可以尝试:
"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)"
]https://stackoverflow.com/questions/67541238
复制相似问题