python随机森林特征重要性_随机森林回归和特征重要性_

我正在努力从我的随机森林回归器中找出特征重要性,我得到一个:AttributeError: 'GridSearchCV' object has no attribute

'feature_importances_'.

有人知道为什么没有属性吗?根据文件应该存在这个属性吗?在

完整代码:from sklearn.ensemble import RandomForestRegressor

from sklearn.model_selection import GridSearchCV

#Running a RandomForestRegressor GridSearchCV to tune the model.

parameter_candidates = {

'n_estimators' : [650, 700, 750, 800],

'min_samples_leaf' : [1, 2, 3],

'max_depth' : [10, 11, 12],

'min_samples_split' : [2, 3, 4, 5, 6]

}

RFR_regr = RandomForestRegressor()

CV_RFR_regr = GridSearchCV(estimator=RFR_regr, param_grid=parameter_candidates, n_jobs=5, verbose=2)

CV_RFR_regr.fit(X_train, y_train)

#Predict with testing set

y_pred = CV_RFR_regr.predict(X_test)

#Extract feature importances

importances = CV_RFR_regr.feature_importances_

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值