from spotpython.data.diabetes import Diabetes
from spotpython.hyperdict.light_hyper_dict import LightHyperDict
from spotpython.fun.hyperlight import HyperLight
from spotpython.utils.init import (fun_control_init, surrogate_control_init, design_control_init)
from spotpython.utils.eda import print_exp_table
from spotpython.spot import Spot
from spotpython.utils.file import get_experiment_filename
from math import inf
from spotpython.hyperparameters.values import set_hyperparameter
PREFIX= "CondNet_01"
data_set = Diabetes()
input_dim = 10
output_dim = 1
cond_dim = 2
fun_control = fun_control_init(
PREFIX= PREFIX,
fun_evals= inf,
max_time= 1 ,
data_set = data_set,
core_model_name= "light.regression.NNCondNetRegressor" ,
hyperdict= LightHyperDict,
_L_in= input_dim - cond_dim,
_L_out= 1 ,
_L_cond= cond_dim,)
fun = HyperLight().fun
set_hyperparameter(fun_control, "optimizer" , [ "Adadelta" , "Adam" , "Adamax" ])
set_hyperparameter(fun_control, "l1" , [3 ,4 ])
set_hyperparameter(fun_control, "epochs" , [3 ,7 ])
set_hyperparameter(fun_control, "batch_size" , [4 ,5 ])
set_hyperparameter(fun_control, "dropout_prob" , [0.0 , 0.025 ])
set_hyperparameter(fun_control, "patience" , [2 ,3 ])
set_hyperparameter(fun_control, "lr_mult" , [0.1 , 20.0 ])
design_control = design_control_init(init_size= 10 )
print_exp_table(fun_control)
module_name: light
submodule_name: regression
model_name: NNCondNetRegressor
| name | type | default | lower | upper | transform |
|----------------|--------|-----------|---------|---------|-----------------------|
| l1 | int | 3 | 3 | 4 | transform_power_2_int |
| epochs | int | 4 | 3 | 7 | transform_power_2_int |
| batch_size | int | 4 | 4 | 5 | transform_power_2_int |
| act_fn | factor | ReLU | 0 | 5 | None |
| optimizer | factor | SGD | 0 | 2 | None |
| dropout_prob | float | 0.01 | 0 | 0.025 | None |
| lr_mult | float | 1.0 | 0.1 | 20 | None |
| patience | int | 2 | 2 | 3 | transform_power_2_int |
| batch_norm | factor | 0 | 0 | 1 | None |
| initialization | factor | Default | 0 | 4 | None |
spot_tuner = Spot(fun= fun,fun_control= fun_control, design_control= design_control)
res = spot_tuner.run()
Experiment saved to CondNet_01_exp.pkl
train_model result: {'val_loss': 24158.83203125, 'hp_metric': 24158.83203125}
train_model result: {'val_loss': 23447.546875, 'hp_metric': 23447.546875}
train_model result: {'val_loss': 7307.08984375, 'hp_metric': 7307.08984375}
train_model result: {'val_loss': 23786.861328125, 'hp_metric': 23786.861328125}
train_model result: {'val_loss': 22770.90625, 'hp_metric': 22770.90625}
train_model result: {'val_loss': 23846.84375, 'hp_metric': 23846.84375}
train_model result: {'val_loss': 23610.291015625, 'hp_metric': 23610.291015625}
train_model result: {'val_loss': 4652.201171875, 'hp_metric': 4652.201171875}
train_model result: {'val_loss': 22452.896484375, 'hp_metric': 22452.896484375}
train_model result: {'val_loss': 22722.826171875, 'hp_metric': 22722.826171875}
train_model result: {'val_loss': 3762.646728515625, 'hp_metric': 3762.646728515625}
spotpython tuning: 3762.646728515625 [----------] 4.58%
train_model result: {'val_loss': 4189.49609375, 'hp_metric': 4189.49609375}
spotpython tuning: 3762.646728515625 [#---------] 8.01%
train_model result: {'val_loss': 3598.41845703125, 'hp_metric': 3598.41845703125}
spotpython tuning: 3598.41845703125 [#---------] 12.40%
train_model result: {'val_loss': 4432.4228515625, 'hp_metric': 4432.4228515625}
spotpython tuning: 3598.41845703125 [##--------] 17.91%
train_model result: {'val_loss': 17434.79296875, 'hp_metric': 17434.79296875}
spotpython tuning: 3598.41845703125 [#####-----] 47.88%
train_model result: {'val_loss': 4271.0537109375, 'hp_metric': 4271.0537109375}
spotpython tuning: 3598.41845703125 [#####-----] 52.47%
train_model result: {'val_loss': 9081.8525390625, 'hp_metric': 9081.8525390625}
spotpython tuning: 3598.41845703125 [######----] 55.25%
train_model result: {'val_loss': 8019.37744140625, 'hp_metric': 8019.37744140625}
spotpython tuning: 3598.41845703125 [######----] 58.85%
train_model result: {'val_loss': 3723.706298828125, 'hp_metric': 3723.706298828125}
spotpython tuning: 3598.41845703125 [#######---] 66.36%
train_model result: {'val_loss': 18928.12109375, 'hp_metric': 18928.12109375}
spotpython tuning: 3598.41845703125 [##########] 97.21%
train_model result: {'val_loss': 4800.939453125, 'hp_metric': 4800.939453125}
spotpython tuning: 3598.41845703125 [##########] 100.00% Done...
Experiment saved to CondNet_01_res.pkl