【发布时间】:2020-11-22 04:48:05
【问题描述】:
ValueError: Invalid parameter estimator for estimator RandomForestRegressor().
Check the list of available parameters with `estimator.get_params().keys()`.
这是我在 RandomForestRegressor 模型上使用 GridSearchCV 时遇到的错误。 这是代码
%%time
from sklearn.model_selection import RandomizedSearchCV
rf_grid= {"estimator__n_estimators ": np.arange(10,100,10),
"estimator__max_depth ": [None,3,5,10],
"estimator__min_sample_split": np.arange(2,20,2),
"estimator__min_sample_leaf" : np.arange(1,20,2),
"estimator__max_features ": [0.5,1,'sqrt','auto'],
"estimator__max_samples" : [10000]
}
rfr_2=RandomForestRegressor()
rs_model= RandomizedSearchCV(estimator=rfr_2,
param_distributions=rf_grid,
n_iter=100,
cv=5,
verbose= True)
rs_model.fit(X_train,Y_train)
【问题讨论】:
标签: python python-3.x scikit-learn random-forest grid-search