Skip to content

Instantly share code, notes, and snippets.

@liannewriting
Last active December 6, 2022 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liannewriting/31465b1d7100fd78c57553e7306f5af9 to your computer and use it in GitHub Desktop.
Save liannewriting/31465b1d7100fd78c57553e7306f5af9 to your computer and use it in GitHub Desktop.
xgboost python machine learning
from skopt import BayesSearchCV
from skopt.space import Real, Categorical, Integer
search_space = {
'clf__max_depth': Integer(2,8),
'clf__learning_rate': Real(0.001, 1.0, prior='log-uniform'),
'clf__subsample': Real(0.5, 1.0),
'clf__colsample_bytree': Real(0.5, 1.0),
'clf__colsample_bylevel': Real(0.5, 1.0),
'clf__colsample_bynode' : Real(0.5, 1.0),
'clf__reg_alpha': Real(0.0, 10.0),
'clf__reg_lambda': Real(0.0, 10.0),
'clf__gamma': Real(0.0, 10.0)
}
opt = BayesSearchCV(pipe, search_space, cv=3, n_iter=10, scoring='roc_auc', random_state=8) # in reality, you may consider setting cv and n_iter to higher values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment