Skip to content

Instantly share code, notes, and snippets.

@smly
Created April 27, 2020 08:43
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 smly/5a2c24a964c221e416895de70abcd55e to your computer and use it in GitHub Desktop.
Save smly/5a2c24a964c221e416895de70abcd55e to your computer and use it in GitHub Desktop.
import optuna.integration.lightgbm as lgb
import numpy as np
import optuna
def test_run() -> None:
params = {
"objective": "binary",
"metric": "binary_logloss",
} # type: Dict
dtrain = lgb.Dataset(np.zeros((100, 4)), label=np.random.randint(0, 2, 100))
dval = lgb.Dataset(np.zeros((100, 4)), label=np.random.randint(0, 2, 100))
study = optuna.create_study()
tuner = lgb.LightGBMTuner(params,
dtrain,
study=study,
valid_sets=dval,
verbose_eval=1,
early_stopping_rounds=1,
num_boost_round=2)
tuner.run()
df_trials = study.trials_dataframe()
assert len(df_trials) == 68
assert len(df_trials[df_trials["state"] == "COMPLETE"]) == 68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment