I use GridSearchCV of scikit-learn to find the best parameters for my XGBClassifier model, I use code like below:
grid_params = {
'n_estimators' : [100, 500, 1000],
'subsample' : [0.01, 0.05]
}
est = xgb.Classifier()
grid_xgb = GridSearchCV(param_grid = grid_params,
estimator = est,
scoring = 'roc_auc',
cv = 4,
verbose = 0)
grid_xgb.fit(X_train, y_train)
print('best estimator:', grid_xgb.best_estimator_)
print('best AUC:', grid_xgb.best_score_)
print('best parameters:', grid_xgb.best_params_)
原创...大约 2 分钟