def get_model(PARAMS): model = XGBClassifier(booster='gbtree', silent=True, nthread=None, random_state=42, base_score=0.5, colsample_bylevel=1, n_estimators=50, reg_lambda=1, objective='binary:logistic') model.max_depth = PARAMS.get("max_depth") model.min_child_weight = PARAMS.get("min_child_weight") model.gamma = PARAMS.get("gamma") model.subsample = PARAMS.get("subsample") model.colsample_bytree = PARAMS.get("colsample_bytree") model.reg_alpha = PARAMS.get('reg_alpha') model.learning_rate = PARAMS.get("learning_rate") return model
best_clf_ind = bestClassifier(Results) res = str(Results[best_clf_ind]) print("The best classifier is %s" % res) # classifier : XGBoost # First we tried to find the best max_depth parameter #Here we take many value of n_estimators to generalise tes_scores = [] depth_range = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 30, 50, 70, 90, 100 ] clf_test = XGBClassifier(n_estimators=10, silent=False) for valeur in depth_range: clf_test.max_depth = valeur clf_test.fit(X_train2, y_train2) y_pr = clf_test.predict_proba(X_test2) tes_scores.append(roc_auc_score(y_test2, y_pr[:, 1])) tes_scores3 = [] clf_test.n_estimators = 100 for valeur in depth_range: clf_test.max_depth = valeur clf_test.fit(X_train2, y_train2) y_pr = clf_test.predict_proba(X_test2) tes_scores3.append(roc_auc_score(y_test2, y_pr[:, 1])) tes_scores2 = [] clf_test.n_estimators = 20 for valeur in depth_range: