2017-09-15 737 views
-1

我用GridSearchCV閱讀微調模型和我遇到以下所示的參數電網傳來:什麼n_estimators和max_features意味着RandomForestRegressor

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) 

在這裏,我沒有得到n_estimator和max_feature的概念。它是否像n_estimator意味着來自數據的記錄數量,max_features是指從數據中選擇的屬性數量?

進一步說後,我得到了這樣的結果:

>> grid_search.best_params_ 
{'max_feature':8, 'n_estimator':30} 

所以事情是,我沒有得到這其實結果想說什麼..

+1

請閱讀文檔:[RandomForestRegressor](http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html)和[用戶指南](http:// scikit-learn .org/stable/modules/ensemble.html#forest-of-randomized-trees) –

+0

@VivekKumar謝謝 –

回答

0

閱讀文檔RandomForest Regressor你可以看到,後n_estimators是在森林中使用的樹木的數量。由於隨機森林是一種由創建多個決策樹組成的集成方法,因此該參數用於控制過程中要使用的樹的數量。

max_features另一方面,確定在查找拆分時要考慮的最大功能數量。有關max_features的更多信息,請閱讀this answer

+0

那麼誰來決定有多少功能將被考慮進行良好的分割?我們在談論什麼功能?數據的屬性是否被視爲功能的特徵或數量? –

+0

@Virtsu由於您使用的是GridSearchCV,此函數根據分類器在數據集上的表現如何,決定「max_features」的最佳值。 –

+0

我已更新我的評論 –