GridSearchCV为我的随机森林崩溃。我需要知道让它发挥作用的原因和解决办法:
# Grid-Search for Random Forest
param_grid = {
'bootstrap': [True],
'n_estimators': [100, 200, 300, 400, 500],
'max_depth': [50, 100, None],
'max_features': ['auto', 200],
'min_impurity_decrease':[0],
'min_samples_split': [2, 5],
'min_samples_leaf': [2, 5],
'oob_score': [True],
'warm_start': [True]
}
# Base-Model for improvement
rf_gridsearch = RandomForestRegressor(random_state=42)
# Grid-Search initiation
rf_gridsearch = GridSearchCV(estimator = rf_gridsearch, param_grid = param_grid,
scoring = 'neg_mean_absolute_error', cv = 5,
n_jobs = -1, verbose = 5)
# Perform the grid search for the model
rf_gridsearch.fit(X_train, y_train)
```发布于 2020-01-24 11:03:50
首先,您正在拟合5 \cdot 3\cdot2\cdot2\cdot2\cdot5=600模型,而n_estimator=500非常大。当然,这取决于您的数据集和计算能力。
我的第一个猜测是,您的笔记本电脑上没有足够的RAM内存(如果您在那里运行它),这就是它崩溃的原因。
如果是这个错误,我建议将数据采样到1/10或更少(取决于您的数据),并在那里搜索最佳的超参数,然后使用整个数据作为最终模型。
https://datascience.stackexchange.com/questions/66973
复制相似问题