Note
Go to the end to download the full example code.
Specify Hyperparameters Manually
It’s natural that you have some specific sets of hyperparameters to try first such as initial learning rate values and the number of leaves. Also, it’s possible that you’ve already tried those sets before having Optuna find better sets of hyperparameters.
Optuna provides two APIs to support such cases:
Passing those sets of hyperparameters and let Optuna evaluate them -
enqueue_trial()
Adding the results of those sets as completed
Trial
s -add_trial()
First Scenario: Have Optuna evaluate your hyperparameters
In this scenario, let’s assume you have some out-of-box sets of hyperparameters but have not evaluated them yet and decided to use Optuna to find better sets of hyperparameters.
Optuna has optuna.study.Study.enqueue_trial()
which lets you pass those sets of
hyperparameters to Optuna and Optuna will evaluate them.
This section walks you through how to use this lit API with LightGBM.
import lightgbm as lgb
import numpy as np
import sklearn.datasets
import sklearn.metrics
from sklearn.model_selection import train_test_split
import optuna
Define the objective function.
def objective(trial):
data, target = sklearn.datasets.load_breast_cancer(return_X_y=True)
train_x, valid_x, train_y, valid_y = train_test_split(data, target, test_size=0.25)
dtrain = lgb.Dataset(train_x, label=train_y)
dvalid = lgb.Dataset(valid_x, label=valid_y)
param = {
"objective": "binary",
"metric": "auc",
"verbosity": -1,
"boosting_type": "gbdt",
"bagging_fraction": min(trial.suggest_float("bagging_fraction", 0.4, 1.0 + 1e-12), 1),
"bagging_freq": trial.suggest_int("bagging_freq", 0, 7),
"min_child_samples": trial.suggest_int("min_child_samples", 5, 100),
}
gbm = lgb.train(param, dtrain, valid_sets=[dvalid])
preds = gbm.predict(valid_x)
pred_labels = np.rint(preds)
accuracy = sklearn.metrics.accuracy_score(valid_y, pred_labels)
return accuracy
Then, construct Study
for hyperparameter optimization.
study = optuna.create_study(direction="maximize", pruner=optuna.pruners.MedianPruner())
Here, we get Optuna evaluate some sets with larger "bagging_fraq"
value and
the default values.
study.enqueue_trial(
{
"bagging_fraction": 1.0,
"bagging_freq": 0,
"min_child_samples": 20,
}
)
study.enqueue_trial(
{
"bagging_fraction": 0.75,
"bagging_freq": 5,
"min_child_samples": 20,
}
)
import logging
import sys
# Add stream handler of stdout to show the messages to see Optuna works expectedly.
optuna.logging.get_logger("optuna").addHandler(logging.StreamHandler(sys.stdout))
study.optimize(objective, n_trials=100, timeout=600)
Trial 0 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 1.0, 'bagging_freq': 0, 'min_child_samples': 20}. Best is trial 0 with value: 0.958041958041958.
Trial 1 finished with value: 0.993006993006993 and parameters: {'bagging_fraction': 0.75, 'bagging_freq': 5, 'min_child_samples': 20}. Best is trial 1 with value: 0.993006993006993.
Trial 2 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.5667965598180923, 'bagging_freq': 0, 'min_child_samples': 57}. Best is trial 1 with value: 0.993006993006993.
Trial 3 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.9592522968429481, 'bagging_freq': 6, 'min_child_samples': 93}. Best is trial 1 with value: 0.993006993006993.
Trial 4 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.6905939312714775, 'bagging_freq': 0, 'min_child_samples': 71}. Best is trial 1 with value: 0.993006993006993.
Trial 5 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.7917168081758649, 'bagging_freq': 6, 'min_child_samples': 43}. Best is trial 1 with value: 0.993006993006993.
Trial 6 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8905737867487955, 'bagging_freq': 2, 'min_child_samples': 20}. Best is trial 1 with value: 0.993006993006993.
Trial 7 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.7608000944081605, 'bagging_freq': 3, 'min_child_samples': 62}. Best is trial 1 with value: 0.993006993006993.
Trial 8 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.4870501976339813, 'bagging_freq': 6, 'min_child_samples': 98}. Best is trial 1 with value: 0.993006993006993.
Trial 9 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.9941985415686777, 'bagging_freq': 1, 'min_child_samples': 41}. Best is trial 1 with value: 0.993006993006993.
Trial 10 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.6345507577189714, 'bagging_freq': 4, 'min_child_samples': 10}. Best is trial 1 with value: 0.993006993006993.
Trial 11 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.8014175441667882, 'bagging_freq': 4, 'min_child_samples': 72}. Best is trial 1 with value: 0.993006993006993.
Trial 12 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.780748370690616, 'bagging_freq': 3, 'min_child_samples': 35}. Best is trial 1 with value: 0.993006993006993.
Trial 13 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.8683790641474027, 'bagging_freq': 5, 'min_child_samples': 32}. Best is trial 1 with value: 0.993006993006993.
Trial 14 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.683318283815793, 'bagging_freq': 3, 'min_child_samples': 6}. Best is trial 1 with value: 0.993006993006993.
Trial 15 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.5870778795576536, 'bagging_freq': 7, 'min_child_samples': 29}. Best is trial 1 with value: 0.993006993006993.
Trial 16 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.4193495376453796, 'bagging_freq': 2, 'min_child_samples': 43}. Best is trial 1 with value: 0.993006993006993.
Trial 17 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.8665439578486598, 'bagging_freq': 5, 'min_child_samples': 19}. Best is trial 1 with value: 0.993006993006993.
Trial 18 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.7476631840030846, 'bagging_freq': 5, 'min_child_samples': 34}. Best is trial 1 with value: 0.993006993006993.
Trial 19 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8319292820931716, 'bagging_freq': 2, 'min_child_samples': 52}. Best is trial 1 with value: 0.993006993006993.
Trial 20 finished with value: 0.9370629370629371 and parameters: {'bagging_fraction': 0.6244121906991366, 'bagging_freq': 4, 'min_child_samples': 13}. Best is trial 1 with value: 0.993006993006993.
Trial 21 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.40240425446561034, 'bagging_freq': 2, 'min_child_samples': 44}. Best is trial 1 with value: 0.993006993006993.
Trial 22 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.4809485584643728, 'bagging_freq': 3, 'min_child_samples': 27}. Best is trial 1 with value: 0.993006993006993.
Trial 23 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.7395650006269183, 'bagging_freq': 1, 'min_child_samples': 49}. Best is trial 1 with value: 0.993006993006993.
Trial 24 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.7063473272717843, 'bagging_freq': 1, 'min_child_samples': 37}. Best is trial 1 with value: 0.993006993006993.
Trial 25 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.5189289282121718, 'bagging_freq': 2, 'min_child_samples': 21}. Best is trial 1 with value: 0.993006993006993.
Trial 26 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.9318658236215482, 'bagging_freq': 3, 'min_child_samples': 62}. Best is trial 1 with value: 0.993006993006993.
Trial 27 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.6570896166063606, 'bagging_freq': 4, 'min_child_samples': 26}. Best is trial 1 with value: 0.993006993006993.
Trial 28 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.41543892723000925, 'bagging_freq': 7, 'min_child_samples': 48}. Best is trial 1 with value: 0.993006993006993.
Trial 29 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.7818440918037743, 'bagging_freq': 5, 'min_child_samples': 16}. Best is trial 1 with value: 0.993006993006993.
Trial 30 finished with value: 1.0 and parameters: {'bagging_fraction': 0.7264415688270085, 'bagging_freq': 3, 'min_child_samples': 39}. Best is trial 30 with value: 1.0.
Trial 31 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.7280909011824227, 'bagging_freq': 3, 'min_child_samples': 39}. Best is trial 30 with value: 1.0.
Trial 32 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.8079397404973361, 'bagging_freq': 2, 'min_child_samples': 56}. Best is trial 30 with value: 1.0.
Trial 33 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.5773345785624884, 'bagging_freq': 4, 'min_child_samples': 23}. Best is trial 30 with value: 1.0.
Trial 34 finished with value: 0.993006993006993 and parameters: {'bagging_fraction': 0.8350281212055093, 'bagging_freq': 1, 'min_child_samples': 33}. Best is trial 30 with value: 1.0.
Trial 35 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.8383835148826626, 'bagging_freq': 0, 'min_child_samples': 32}. Best is trial 30 with value: 1.0.
Trial 36 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.918440554836272, 'bagging_freq': 1, 'min_child_samples': 81}. Best is trial 30 with value: 1.0.
Trial 37 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.7705650235539575, 'bagging_freq': 0, 'min_child_samples': 33}. Best is trial 30 with value: 1.0.
Trial 38 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.7111168904858131, 'bagging_freq': 6, 'min_child_samples': 26}. Best is trial 30 with value: 1.0.
Trial 39 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.6803293935091843, 'bagging_freq': 3, 'min_child_samples': 36}. Best is trial 30 with value: 1.0.
Trial 40 finished with value: 0.993006993006993 and parameters: {'bagging_fraction': 0.8265438332453564, 'bagging_freq': 5, 'min_child_samples': 5}. Best is trial 30 with value: 1.0.
Trial 41 finished with value: 0.9300699300699301 and parameters: {'bagging_fraction': 0.8048492289878636, 'bagging_freq': 5, 'min_child_samples': 5}. Best is trial 30 with value: 1.0.
Trial 42 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8395520453591413, 'bagging_freq': 6, 'min_child_samples': 10}. Best is trial 30 with value: 1.0.
Trial 43 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8738617723352113, 'bagging_freq': 4, 'min_child_samples': 15}. Best is trial 30 with value: 1.0.
Trial 44 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.756420943610042, 'bagging_freq': 6, 'min_child_samples': 22}. Best is trial 30 with value: 1.0.
Trial 45 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.9123407371050084, 'bagging_freq': 5, 'min_child_samples': 12}. Best is trial 30 with value: 1.0.
Trial 46 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.8203781626971833, 'bagging_freq': 4, 'min_child_samples': 17}. Best is trial 30 with value: 1.0.
Trial 47 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.7820560783217352, 'bagging_freq': 3, 'min_child_samples': 30}. Best is trial 30 with value: 1.0.
Trial 48 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.9541972847355754, 'bagging_freq': 5, 'min_child_samples': 46}. Best is trial 30 with value: 1.0.
Trial 49 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.8633907245887565, 'bagging_freq': 1, 'min_child_samples': 9}. Best is trial 30 with value: 1.0.
Trial 50 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.6584872114224732, 'bagging_freq': 7, 'min_child_samples': 39}. Best is trial 30 with value: 1.0.
Trial 51 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.7201424744090775, 'bagging_freq': 2, 'min_child_samples': 41}. Best is trial 30 with value: 1.0.
Trial 52 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.7604058072903314, 'bagging_freq': 2, 'min_child_samples': 55}. Best is trial 30 with value: 1.0.
Trial 53 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8502090897538374, 'bagging_freq': 3, 'min_child_samples': 50}. Best is trial 30 with value: 1.0.
Trial 54 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8929622599258189, 'bagging_freq': 2, 'min_child_samples': 43}. Best is trial 30 with value: 1.0.
Trial 55 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.791271960070665, 'bagging_freq': 1, 'min_child_samples': 36}. Best is trial 30 with value: 1.0.
Trial 56 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.5419352611029957, 'bagging_freq': 3, 'min_child_samples': 27}. Best is trial 30 with value: 1.0.
Trial 57 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.605249939950689, 'bagging_freq': 2, 'min_child_samples': 66}. Best is trial 30 with value: 1.0.
Trial 58 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.4370205723140215, 'bagging_freq': 4, 'min_child_samples': 45}. Best is trial 30 with value: 1.0.
Trial 59 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8179692729597261, 'bagging_freq': 2, 'min_child_samples': 24}. Best is trial 30 with value: 1.0.
Trial 60 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.7380862994126391, 'bagging_freq': 0, 'min_child_samples': 19}. Best is trial 30 with value: 1.0.
Trial 61 finished with value: 0.993006993006993 and parameters: {'bagging_fraction': 0.8218516543781592, 'bagging_freq': 4, 'min_child_samples': 18}. Best is trial 30 with value: 1.0.
Trial 62 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6895344214948829, 'bagging_freq': 4, 'min_child_samples': 30}. Best is trial 30 with value: 1.0.
Trial 63 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.7711036168151518, 'bagging_freq': 5, 'min_child_samples': 7}. Best is trial 30 with value: 1.0.
Trial 64 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.7955806732921321, 'bagging_freq': 6, 'min_child_samples': 13}. Best is trial 30 with value: 1.0.
Trial 65 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.8916575957769006, 'bagging_freq': 3, 'min_child_samples': 40}. Best is trial 30 with value: 1.0.
Trial 66 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.8274176020125309, 'bagging_freq': 4, 'min_child_samples': 35}. Best is trial 30 with value: 1.0.
Trial 67 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.7514853393830722, 'bagging_freq': 5, 'min_child_samples': 18}. Best is trial 30 with value: 1.0.
Trial 68 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.8571965020846143, 'bagging_freq': 3, 'min_child_samples': 29}. Best is trial 30 with value: 1.0.
Trial 69 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.6546727339844248, 'bagging_freq': 4, 'min_child_samples': 87}. Best is trial 30 with value: 1.0.
Trial 70 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.727963785161354, 'bagging_freq': 3, 'min_child_samples': 23}. Best is trial 30 with value: 1.0.
Trial 71 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.8186639222069073, 'bagging_freq': 4, 'min_child_samples': 16}. Best is trial 30 with value: 1.0.
Trial 72 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.8085227563413105, 'bagging_freq': 4, 'min_child_samples': 18}. Best is trial 30 with value: 1.0.
Trial 73 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.7805930122150956, 'bagging_freq': 5, 'min_child_samples': 8}. Best is trial 30 with value: 1.0.
Trial 74 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8783007363154546, 'bagging_freq': 4, 'min_child_samples': 11}. Best is trial 30 with value: 1.0.
Trial 75 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.8388417802806034, 'bagging_freq': 3, 'min_child_samples': 33}. Best is trial 30 with value: 1.0.
Trial 76 finished with value: 0.9300699300699301 and parameters: {'bagging_fraction': 0.7077104374913539, 'bagging_freq': 5, 'min_child_samples': 38}. Best is trial 30 with value: 1.0.
Trial 77 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.8235263443141945, 'bagging_freq': 1, 'min_child_samples': 14}. Best is trial 30 with value: 1.0.
Trial 78 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.7430384375862482, 'bagging_freq': 4, 'min_child_samples': 25}. Best is trial 30 with value: 1.0.
Trial 79 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.46179666721644136, 'bagging_freq': 1, 'min_child_samples': 5}. Best is trial 30 with value: 1.0.
Trial 80 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.772882166650904, 'bagging_freq': 5, 'min_child_samples': 43}. Best is trial 30 with value: 1.0.
Trial 81 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6047776918220702, 'bagging_freq': 2, 'min_child_samples': 63}. Best is trial 30 with value: 1.0.
Trial 82 finished with value: 0.9370629370629371 and parameters: {'bagging_fraction': 0.8478544309867581, 'bagging_freq': 2, 'min_child_samples': 59}. Best is trial 30 with value: 1.0.
Trial 83 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.5001305918161209, 'bagging_freq': 2, 'min_child_samples': 66}. Best is trial 30 with value: 1.0.
Trial 84 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.5575821299395548, 'bagging_freq': 3, 'min_child_samples': 68}. Best is trial 30 with value: 1.0.
Trial 85 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.671501267767402, 'bagging_freq': 1, 'min_child_samples': 48}. Best is trial 30 with value: 1.0.
Trial 86 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6255615702870693, 'bagging_freq': 3, 'min_child_samples': 76}. Best is trial 30 with value: 1.0.
Trial 87 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.7984019296979965, 'bagging_freq': 2, 'min_child_samples': 22}. Best is trial 30 with value: 1.0.
Trial 88 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.7859127573296656, 'bagging_freq': 5, 'min_child_samples': 52}. Best is trial 30 with value: 1.0.
Trial 89 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.760941984334147, 'bagging_freq': 0, 'min_child_samples': 96}. Best is trial 30 with value: 1.0.
Trial 90 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.9052743198523414, 'bagging_freq': 4, 'min_child_samples': 31}. Best is trial 30 with value: 1.0.
Trial 91 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.798736311517148, 'bagging_freq': 6, 'min_child_samples': 13}. Best is trial 30 with value: 1.0.
Trial 92 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.8114346731703875, 'bagging_freq': 6, 'min_child_samples': 10}. Best is trial 30 with value: 1.0.
Trial 93 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8320799924982192, 'bagging_freq': 6, 'min_child_samples': 20}. Best is trial 30 with value: 1.0.
Trial 94 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.6947850747522928, 'bagging_freq': 6, 'min_child_samples': 12}. Best is trial 30 with value: 1.0.
Trial 95 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.728579180839269, 'bagging_freq': 7, 'min_child_samples': 16}. Best is trial 30 with value: 1.0.
Trial 96 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.8758657875028313, 'bagging_freq': 3, 'min_child_samples': 41}. Best is trial 30 with value: 1.0.
Trial 97 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.793261266567, 'bagging_freq': 7, 'min_child_samples': 27}. Best is trial 30 with value: 1.0.
Trial 98 finished with value: 0.9370629370629371 and parameters: {'bagging_fraction': 0.7658187848678442, 'bagging_freq': 3, 'min_child_samples': 18}. Best is trial 30 with value: 1.0.
Trial 99 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.8591840626239838, 'bagging_freq': 4, 'min_child_samples': 46}. Best is trial 30 with value: 1.0.
Second scenario: Have Optuna utilize already evaluated hyperparameters
In this scenario, let’s assume you have some out-of-box sets of hyperparameters and you have already evaluated them but the results are not desirable so that you are thinking of using Optuna.
Optuna has optuna.study.Study.add_trial()
which lets you register those results
to Optuna and then Optuna will sample hyperparameters taking them into account.
In this section, the objective
is the same as the first scenario.
study = optuna.create_study(direction="maximize", pruner=optuna.pruners.MedianPruner())
study.add_trial(
optuna.trial.create_trial(
params={
"bagging_fraction": 1.0,
"bagging_freq": 0,
"min_child_samples": 20,
},
distributions={
"bagging_fraction": optuna.distributions.FloatDistribution(0.4, 1.0 + 1e-12),
"bagging_freq": optuna.distributions.IntDistribution(0, 7),
"min_child_samples": optuna.distributions.IntDistribution(5, 100),
},
value=0.94,
)
)
study.add_trial(
optuna.trial.create_trial(
params={
"bagging_fraction": 0.75,
"bagging_freq": 5,
"min_child_samples": 20,
},
distributions={
"bagging_fraction": optuna.distributions.FloatDistribution(0.4, 1.0 + 1e-12),
"bagging_freq": optuna.distributions.IntDistribution(0, 7),
"min_child_samples": optuna.distributions.IntDistribution(5, 100),
},
value=0.95,
)
)
study.optimize(objective, n_trials=100, timeout=600)
A new study created in memory with name: no-name-58f0b8da-3896-4041-af09-a7cd876c1925
Trial 2 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.44183896642488707, 'bagging_freq': 0, 'min_child_samples': 78}. Best is trial 2 with value: 0.951048951048951.
Trial 3 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.9632622958854923, 'bagging_freq': 3, 'min_child_samples': 66}. Best is trial 3 with value: 0.9790209790209791.
Trial 4 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.6393205809224267, 'bagging_freq': 7, 'min_child_samples': 17}. Best is trial 4 with value: 0.986013986013986.
Trial 5 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.8717448173507834, 'bagging_freq': 1, 'min_child_samples': 47}. Best is trial 4 with value: 0.986013986013986.
Trial 6 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.5632843180195477, 'bagging_freq': 5, 'min_child_samples': 46}. Best is trial 4 with value: 0.986013986013986.
Trial 7 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.4639059839458685, 'bagging_freq': 3, 'min_child_samples': 44}. Best is trial 4 with value: 0.986013986013986.
Trial 8 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.5581297827683743, 'bagging_freq': 1, 'min_child_samples': 86}. Best is trial 4 with value: 0.986013986013986.
Trial 9 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.5136069235091691, 'bagging_freq': 1, 'min_child_samples': 42}. Best is trial 4 with value: 0.986013986013986.
Trial 10 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.6960471895245134, 'bagging_freq': 7, 'min_child_samples': 8}. Best is trial 4 with value: 0.986013986013986.
Trial 11 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.6975116519220218, 'bagging_freq': 3, 'min_child_samples': 65}. Best is trial 4 with value: 0.986013986013986.
Trial 12 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.8447308043751045, 'bagging_freq': 7, 'min_child_samples': 68}. Best is trial 4 with value: 0.986013986013986.
Trial 13 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.9882000953407825, 'bagging_freq': 4, 'min_child_samples': 94}. Best is trial 4 with value: 0.986013986013986.
Trial 14 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.6185943343168564, 'bagging_freq': 6, 'min_child_samples': 30}. Best is trial 4 with value: 0.986013986013986.
Trial 15 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.8115116459655697, 'bagging_freq': 4, 'min_child_samples': 60}. Best is trial 4 with value: 0.986013986013986.
Trial 16 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.9039243595941963, 'bagging_freq': 2, 'min_child_samples': 75}. Best is trial 4 with value: 0.986013986013986.
Trial 17 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.6479331834339572, 'bagging_freq': 5, 'min_child_samples': 5}. Best is trial 4 with value: 0.986013986013986.
Trial 18 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.7677320267286811, 'bagging_freq': 2, 'min_child_samples': 30}. Best is trial 4 with value: 0.986013986013986.
Trial 19 finished with value: 1.0 and parameters: {'bagging_fraction': 0.617863861492608, 'bagging_freq': 6, 'min_child_samples': 61}. Best is trial 19 with value: 1.0.
Trial 20 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.6289999542702491, 'bagging_freq': 6, 'min_child_samples': 54}. Best is trial 19 with value: 1.0.
Trial 21 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.6218812102038069, 'bagging_freq': 6, 'min_child_samples': 56}. Best is trial 19 with value: 1.0.
Trial 22 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.5644594241216093, 'bagging_freq': 6, 'min_child_samples': 34}. Best is trial 19 with value: 1.0.
Trial 23 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.6494433898283433, 'bagging_freq': 7, 'min_child_samples': 55}. Best is trial 19 with value: 1.0.
Trial 24 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.4937201119249267, 'bagging_freq': 6, 'min_child_samples': 74}. Best is trial 19 with value: 1.0.
Trial 25 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.741773424197723, 'bagging_freq': 7, 'min_child_samples': 37}. Best is trial 19 with value: 1.0.
Trial 26 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.40461036825785457, 'bagging_freq': 5, 'min_child_samples': 21}. Best is trial 19 with value: 1.0.
Trial 27 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.598442415160279, 'bagging_freq': 6, 'min_child_samples': 51}. Best is trial 19 with value: 1.0.
Trial 28 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.6813644572164579, 'bagging_freq': 7, 'min_child_samples': 85}. Best is trial 19 with value: 1.0.
Trial 29 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.661909178522923, 'bagging_freq': 4, 'min_child_samples': 20}. Best is trial 19 with value: 1.0.
Trial 30 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.5750777945737311, 'bagging_freq': 6, 'min_child_samples': 12}. Best is trial 19 with value: 1.0.
Trial 31 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.6401094697446003, 'bagging_freq': 7, 'min_child_samples': 56}. Best is trial 19 with value: 1.0.
Trial 32 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.7344752858343138, 'bagging_freq': 7, 'min_child_samples': 60}. Best is trial 19 with value: 1.0.
Trial 33 finished with value: 0.993006993006993 and parameters: {'bagging_fraction': 0.5189326813835204, 'bagging_freq': 5, 'min_child_samples': 52}. Best is trial 19 with value: 1.0.
Trial 34 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.523819031220182, 'bagging_freq': 5, 'min_child_samples': 100}. Best is trial 19 with value: 1.0.
Trial 35 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.5305803403133827, 'bagging_freq': 5, 'min_child_samples': 68}. Best is trial 19 with value: 1.0.
Trial 36 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.5880002676480329, 'bagging_freq': 6, 'min_child_samples': 50}. Best is trial 19 with value: 1.0.
Trial 37 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.45992078072417353, 'bagging_freq': 6, 'min_child_samples': 15}. Best is trial 19 with value: 1.0.
Trial 38 finished with value: 0.9090909090909091 and parameters: {'bagging_fraction': 0.6105238948649514, 'bagging_freq': 4, 'min_child_samples': 38}. Best is trial 19 with value: 1.0.
Trial 39 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.48979456788426023, 'bagging_freq': 5, 'min_child_samples': 25}. Best is trial 19 with value: 1.0.
Trial 40 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.538587031808986, 'bagging_freq': 5, 'min_child_samples': 83}. Best is trial 19 with value: 1.0.
Trial 41 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.6578034383417315, 'bagging_freq': 7, 'min_child_samples': 62}. Best is trial 19 with value: 1.0.
Trial 42 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6829227399393247, 'bagging_freq': 7, 'min_child_samples': 54}. Best is trial 19 with value: 1.0.
Trial 43 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.7322240282389547, 'bagging_freq': 6, 'min_child_samples': 43}. Best is trial 19 with value: 1.0.
Trial 44 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.7856867303647044, 'bagging_freq': 7, 'min_child_samples': 49}. Best is trial 19 with value: 1.0.
Trial 45 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.7024243312006027, 'bagging_freq': 6, 'min_child_samples': 70}. Best is trial 19 with value: 1.0.
Trial 46 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.6235422038078181, 'bagging_freq': 7, 'min_child_samples': 46}. Best is trial 19 with value: 1.0.
Trial 47 finished with value: 0.9300699300699301 and parameters: {'bagging_fraction': 0.7187047715071163, 'bagging_freq': 6, 'min_child_samples': 63}. Best is trial 19 with value: 1.0.
Trial 48 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.5538891119945011, 'bagging_freq': 7, 'min_child_samples': 58}. Best is trial 19 with value: 1.0.
Trial 49 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.40866146978393636, 'bagging_freq': 5, 'min_child_samples': 73}. Best is trial 19 with value: 1.0.
Trial 50 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.5902259501361193, 'bagging_freq': 0, 'min_child_samples': 80}. Best is trial 19 with value: 1.0.
Trial 51 finished with value: 0.9440559440559441 and parameters: {'bagging_fraction': 0.6594842507086187, 'bagging_freq': 7, 'min_child_samples': 56}. Best is trial 19 with value: 1.0.
Trial 52 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.6402025865793538, 'bagging_freq': 7, 'min_child_samples': 53}. Best is trial 19 with value: 1.0.
Trial 53 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.6243795331125025, 'bagging_freq': 6, 'min_child_samples': 64}. Best is trial 19 with value: 1.0.
Trial 54 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6769649365182173, 'bagging_freq': 7, 'min_child_samples': 41}. Best is trial 19 with value: 1.0.
Trial 55 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.4974471843993803, 'bagging_freq': 6, 'min_child_samples': 47}. Best is trial 19 with value: 1.0.
Trial 56 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.6343009435089778, 'bagging_freq': 7, 'min_child_samples': 58}. Best is trial 19 with value: 1.0.
Trial 57 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.7143875943872218, 'bagging_freq': 6, 'min_child_samples': 70}. Best is trial 19 with value: 1.0.
Trial 58 finished with value: 0.993006993006993 and parameters: {'bagging_fraction': 0.6073895500932414, 'bagging_freq': 7, 'min_child_samples': 53}. Best is trial 19 with value: 1.0.
Trial 59 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.575759561864122, 'bagging_freq': 3, 'min_child_samples': 35}. Best is trial 19 with value: 1.0.
Trial 60 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.5505556627187195, 'bagging_freq': 5, 'min_child_samples': 30}. Best is trial 19 with value: 1.0.
Trial 61 finished with value: 0.9300699300699301 and parameters: {'bagging_fraction': 0.6030318431385326, 'bagging_freq': 7, 'min_child_samples': 54}. Best is trial 19 with value: 1.0.
Trial 62 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.6436391309380831, 'bagging_freq': 7, 'min_child_samples': 50}. Best is trial 19 with value: 1.0.
Trial 63 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.6770004331775611, 'bagging_freq': 7, 'min_child_samples': 61}. Best is trial 19 with value: 1.0.
Trial 64 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.6037199322687296, 'bagging_freq': 6, 'min_child_samples': 65}. Best is trial 19 with value: 1.0.
Trial 65 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.5828059664631201, 'bagging_freq': 7, 'min_child_samples': 57}. Best is trial 19 with value: 1.0.
Trial 66 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.6512292624919409, 'bagging_freq': 6, 'min_child_samples': 40}. Best is trial 19 with value: 1.0.
Trial 67 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.7567057527669051, 'bagging_freq': 4, 'min_child_samples': 45}. Best is trial 19 with value: 1.0.
Trial 68 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6162597517384801, 'bagging_freq': 6, 'min_child_samples': 52}. Best is trial 19 with value: 1.0.
Trial 69 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.5061941880427944, 'bagging_freq': 2, 'min_child_samples': 67}. Best is trial 19 with value: 1.0.
Trial 70 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.9405792463376449, 'bagging_freq': 7, 'min_child_samples': 60}. Best is trial 19 with value: 1.0.
Trial 71 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.7218318564917572, 'bagging_freq': 6, 'min_child_samples': 42}. Best is trial 19 with value: 1.0.
Trial 72 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.8132348305554957, 'bagging_freq': 5, 'min_child_samples': 49}. Best is trial 19 with value: 1.0.
Trial 73 finished with value: 0.993006993006993 and parameters: {'bagging_fraction': 0.6958094788842548, 'bagging_freq': 6, 'min_child_samples': 55}. Best is trial 19 with value: 1.0.
Trial 74 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6917076267659766, 'bagging_freq': 7, 'min_child_samples': 91}. Best is trial 19 with value: 1.0.
Trial 75 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.6636569243137013, 'bagging_freq': 6, 'min_child_samples': 56}. Best is trial 19 with value: 1.0.
Trial 76 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.6327691880245486, 'bagging_freq': 7, 'min_child_samples': 54}. Best is trial 19 with value: 1.0.
Trial 77 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.704943091334637, 'bagging_freq': 6, 'min_child_samples': 26}. Best is trial 19 with value: 1.0.
Trial 78 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.5656646716280952, 'bagging_freq': 5, 'min_child_samples': 48}. Best is trial 19 with value: 1.0.
Trial 79 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6705325369934918, 'bagging_freq': 7, 'min_child_samples': 10}. Best is trial 19 with value: 1.0.
Trial 80 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.43154824014653903, 'bagging_freq': 6, 'min_child_samples': 62}. Best is trial 19 with value: 1.0.
Trial 81 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.7398604526641287, 'bagging_freq': 6, 'min_child_samples': 52}. Best is trial 19 with value: 1.0.
Trial 82 finished with value: 0.9370629370629371 and parameters: {'bagging_fraction': 0.6883533892954915, 'bagging_freq': 6, 'min_child_samples': 43}. Best is trial 19 with value: 1.0.
Trial 83 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.650552427746657, 'bagging_freq': 7, 'min_child_samples': 59}. Best is trial 19 with value: 1.0.
Trial 84 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.5938240327904475, 'bagging_freq': 5, 'min_child_samples': 56}. Best is trial 19 with value: 1.0.
Trial 85 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.789682571662358, 'bagging_freq': 6, 'min_child_samples': 18}. Best is trial 19 with value: 1.0.
Trial 86 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.6177706103110726, 'bagging_freq': 7, 'min_child_samples': 45}. Best is trial 19 with value: 1.0.
Trial 87 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.762110193675368, 'bagging_freq': 6, 'min_child_samples': 54}. Best is trial 19 with value: 1.0.
Trial 88 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.7327738669781054, 'bagging_freq': 7, 'min_child_samples': 64}. Best is trial 19 with value: 1.0.
Trial 89 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.544192546085069, 'bagging_freq': 5, 'min_child_samples': 51}. Best is trial 19 with value: 1.0.
Trial 90 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.47268391583429775, 'bagging_freq': 7, 'min_child_samples': 70}. Best is trial 19 with value: 1.0.
Trial 91 finished with value: 0.958041958041958 and parameters: {'bagging_fraction': 0.6335032271852867, 'bagging_freq': 7, 'min_child_samples': 57}. Best is trial 19 with value: 1.0.
Trial 92 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.6393802658155826, 'bagging_freq': 7, 'min_child_samples': 58}. Best is trial 19 with value: 1.0.
Trial 93 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.7056496292314441, 'bagging_freq': 7, 'min_child_samples': 60}. Best is trial 19 with value: 1.0.
Trial 94 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.6703858292012282, 'bagging_freq': 6, 'min_child_samples': 47}. Best is trial 19 with value: 1.0.
Trial 95 finished with value: 0.986013986013986 and parameters: {'bagging_fraction': 0.6076485083943894, 'bagging_freq': 7, 'min_child_samples': 6}. Best is trial 19 with value: 1.0.
Trial 96 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.6313066510748804, 'bagging_freq': 6, 'min_child_samples': 66}. Best is trial 19 with value: 1.0.
Trial 97 finished with value: 0.972027972027972 and parameters: {'bagging_fraction': 0.5238880438200637, 'bagging_freq': 7, 'min_child_samples': 54}. Best is trial 19 with value: 1.0.
Trial 98 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.5701226624185931, 'bagging_freq': 6, 'min_child_samples': 39}. Best is trial 19 with value: 1.0.
Trial 99 finished with value: 0.9790209790209791 and parameters: {'bagging_fraction': 0.691321766740138, 'bagging_freq': 7, 'min_child_samples': 33}. Best is trial 19 with value: 1.0.
Trial 100 finished with value: 0.965034965034965 and parameters: {'bagging_fraction': 0.6519181348704164, 'bagging_freq': 6, 'min_child_samples': 50}. Best is trial 19 with value: 1.0.
Trial 101 finished with value: 0.951048951048951 and parameters: {'bagging_fraction': 0.5799295212986736, 'bagging_freq': 3, 'min_child_samples': 52}. Best is trial 19 with value: 1.0.
Total running time of the script: (0 minutes 14.898 seconds)