Created
April 27, 2020 08:43
-
-
Save smly/5a2c24a964c221e416895de70abcd55e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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