我创建了一个GradientBoostingRegressor模型。
我在GridSearchCV函数中使用scoring
参数来返回MSE评分。
我想知道如果我在param_grids
中使用criterion
,是否会改变我的模型?哪种方式是正确的?
GBR = GradientBoostingRegressor()
param_grids = {
'learning_rate' : [0.01, 0.05, 0.07, 0.1, 0.3, 0.5 ],
'n_estimators' : [50,60,70,80,90,100],
'max_depth' : [1, 2, 3, 4],
'min_samples_leaf' : [1,2,3,5,10,15],
'min_samples_split': [2,3,4,5,10],
#'criterion' : ['mse']
}
kf = KFold(n_splits=3, random_state=42, shuffle=True)
gs = GridSearchCV(estimator=GBR, param_grid = param_grids , cv = kf, n_jobs=-1, return_train_score=True, scoring='neg_mean_squared_error')
回答:
criterion方法用于评估树中的分割。scoring方法用于评估整个模型的质量。
如果你想知道它是否会改变你的模型,为什么不直接测试一下呢?这就是GridSearchCV擅长的。默认值是friedman_mse,所以:
param_grids = {
'learning_rate' : [0.01, 0.05, 0.07, 0.1, 0.3, 0.5 ],
'n_estimators' : [50,60,70,80,90,100],
'max_depth' : [1, 2, 3, 4],
'min_samples_leaf' : [1,2,3,5,10,15],
'min_samples_split': [2,3,4,5,10],
'criterion' : ['friedman_mse', 'mse']
}