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()
train_model result: {'val_loss': 24159.23828125, 'hp_metric': 24159.23828125}
train_model result: {'val_loss': 23455.20703125, 'hp_metric': 23455.20703125}
train_model result: {'val_loss': 43761.7265625, 'hp_metric': 43761.7265625}
train_model result: {'val_loss': 24069.580078125, 'hp_metric': 24069.580078125}
train_model result: {'val_loss': 22378.6015625, 'hp_metric': 22378.6015625}
train_model result: {'val_loss': 23910.111328125, 'hp_metric': 23910.111328125}
train_model result: {'val_loss': 23796.3828125, 'hp_metric': 23796.3828125}
train_model result: {'val_loss': 3585.37548828125, 'hp_metric': 3585.37548828125}
train_model result: {'val_loss': 22366.2421875, 'hp_metric': 22366.2421875}
train_model result: {'val_loss': 22662.296875, 'hp_metric': 22662.296875}
train_model result: {'val_loss': 4858.8212890625, 'hp_metric': 4858.8212890625}
spotpython tuning: 3585.37548828125 [#---------] 7.85%
train_model result: {'val_loss': 2978.2021484375, 'hp_metric': 2978.2021484375}
spotpython tuning: 2978.2021484375 [#---------] 12.76%
train_model result: {'val_loss': 3981.192626953125, 'hp_metric': 3981.192626953125}
spotpython tuning: 2978.2021484375 [##--------] 15.84%
train_model result: {'val_loss': 2909.39208984375, 'hp_metric': 2909.39208984375}
spotpython tuning: 2909.39208984375 [##--------] 20.34%
train_model result: {'val_loss': 5174.12109375, 'hp_metric': 5174.12109375}
spotpython tuning: 2909.39208984375 [##--------] 23.83%
train_model result: {'val_loss': 22454.35546875, 'hp_metric': 22454.35546875}
spotpython tuning: 2909.39208984375 [###-------] 34.12%
train_model result: {'val_loss': 3955.571044921875, 'hp_metric': 3955.571044921875}
spotpython tuning: 2909.39208984375 [####------] 38.67%
train_model result: {'val_loss': 16310.7568359375, 'hp_metric': 16310.7568359375}
spotpython tuning: 2909.39208984375 [#######---] 65.76%
train_model result: {'val_loss': 4214.85009765625, 'hp_metric': 4214.85009765625}
spotpython tuning: 2909.39208984375 [#######---] 70.67%
train_model result: {'val_loss': 4863.47119140625, 'hp_metric': 4863.47119140625}
spotpython tuning: 2909.39208984375 [########--] 75.61%
train_model result: {'val_loss': 4874.6474609375, 'hp_metric': 4874.6474609375}
spotpython tuning: 2909.39208984375 [########--] 80.77%
train_model result: {'val_loss': 3189.736083984375, 'hp_metric': 3189.736083984375}
spotpython tuning: 2909.39208984375 [#########-] 89.34%
train_model result: {'val_loss': 4701.22802734375, 'hp_metric': 4701.22802734375}
spotpython tuning: 2909.39208984375 [##########] 95.92%
train_model result: {'val_loss': 3343.5302734375, 'hp_metric': 3343.5302734375}
spotpython tuning: 2909.39208984375 [##########] 100.00% Done...
Experiment saved to CondNet_01_res.pkl