text_plain_output_1.png
X_train, X_valid, y_train, y_valid = train_test_split(trn_data[features], trn_data[target_feature])
def objective(trial):
    n_estimators = trial.suggest_int('n_estimators', 8, 2048)
    max_depth = trial.suggest_int('max_depth', 2, 16)
    learning_rate = trial.suggest_float('learning_rate', 0.01, 0.2)
    subsample = trial.suggest_float('subsample', 0.5, 1)
    colsample_bytree = trial.suggest_float('colsample_bytree', 0.5, 1)
    reg_lambda = trial.suggest_float('reg_lambda', 1, 20)
    reg_alpha = trial.suggest_float('reg_alpha', 0, 20)
    gamma = trial.suggest_float('gamma', 0, 20)
    min_child_weight = trial.suggest_int('min_child_weight', 0, 128)
    clf = XGBClassifier(n_estimators=n_estimators, learning_rate=learning_rate, max_depth=max_depth, subsample=subsample, colsample_bytree=colsample_bytree, reg_lambda=reg_lambda, reg_alpha=reg_alpha, gamma=gamma, min_child_weight=min_child_weight, random_state=69, objective='binary:logistic', tree_method='gpu_hist')
    clf.fit(X_train, y_train)
    valid_pred = clf.predict(X_valid)
    score = accuracy_score(y_valid, valid_pred)
    return score