我正在阅读有关使用GridSearchCV精调模型的信息,并且遇到了如下所示的参数网格:
param_grid = [
{'n_estimators': [3, 10, 30], 'max_features': [2, 4, 6, 8]},
{'bootstrap': [False], 'n_estimators': [3, 10], 'max_features': [2, 3, 4]},
]
forest_reg = RandomForestRegressor(random_state=42)
# train across 5 folds, that's a total of (12+6)*5=90 rounds of training
grid_search = GridSearchCV(forest_reg, param_grid, cv=5,
scoring='neg_mean_squared_error')
grid_search.fit(housing_prepared, housing_labels)
Run Code Online (Sandbox Code Playgroud)
在这里,我没有得到n_estimator和max_feature的概念。就像n_estimator表示从数据中记录的数量,而max_features意味着从数据中选择的属性的数量一样吗?
经过进一步研究,我得到了以下结果:
>> grid_search.best_params_
{'max_feature':8, 'n_estimator':30}
Run Code Online (Sandbox Code Playgroud)
所以事情是我没有得到真正的结果。
阅读有关RandomForest Regressor的文档后,您可以看到这n_estimators是林中要使用的树数。由于“随机森林”是一种包括创建多个决策树的整体方法,因此该参数用于控制流程中要使用的树的数量。
max_features另一方面,确定寻找拆分时要考虑的最大特征数。有关更多信息,请max_features阅读此答案。
| 归档时间: |
|
| 查看次数: |
11196 次 |
| 最近记录: |