def tune_xgb_cv(params_untuned,params_sklearn,scoring='roc_auc', n_jobs=4, cv=5,verbose=10):
for param_untuned in params_untuned:
print '========== ', param_untuned, ' =============='
print_params(params_sklearn)
estimator = xgb.XGBClassifier(**params_sklearn)
# if(param_untuned.keys()[0] == 'n_estimators'):
# cv = 1
grid_search = GridSearchCV(estimator, param_grid=param_untuned, scoring=scoring, n_jobs=n_jobs, cv=cv, verbose=verbose)
grid_search.fit(x, y)
df = pd.DataFrame(grid_search.cv_results_)[['params', 'mean_train_score', 'mean_test_score']]
print df
print 'the best_params : ', grid_search.best_params_
print 'the best_score : ', grid_search.best_score_
for k,v in grid_search.best_params_.items():
params_sklearn[k] = v
return estimator,params_sklearn
xg_train_slower.py 文件源码
python
阅读 15
收藏 0
点赞 0
评论 0
评论列表
文章目录