def xgb_model(train_data, train_label, test_data, test_label):
clf = xgb.XGBClassifier(max_depth=7,
min_child_weight=1,
learning_rate=0.1,
n_estimators=500,
silent=True,
objective='binary:logistic',
gamma=0,
max_delta_step=0,
subsample=1,
colsample_bytree=1,
colsample_bylevel=1,
reg_alpha=0,
reg_lambda=0,
scale_pos_weight=1,
seed=1,
missing=None)
clf.fit(train_data, train_label, eval_metric='auc', verbose=True,
eval_set=[(test_data, test_label)], early_stopping_rounds=100)
y_pre = clf.predict(test_data)
y_pro = clf.predict_proba(test_data)[:, 1]
#print "AUC Score : %f" % metrics.roc_auc_score(test_label, y_pro)
#print"Accuracy : %.4g" % metrics.accuracy_score(test_label, y_pre)
return clf
评论列表
文章目录