예제 #1
0
def tune_meta_learner():
    cs = build_configspace()
    def_value = obj_function(cs.get_default_configuration())
    print("Default Value: %.2f" % (def_value))

    bo = BayesianOptimization(obj_function, cs, max_runs=50, time_limit_per_trial=1200)
    bo.run()
    inc_value = bo.get_incumbent()
    config = inc_value[0][0]

    print('Best hyperparameter config found', config)
    return config
예제 #2
0
def tune_meta_learner():
    cs = build_configspace()
    def_value = objective_function(cs.get_default_configuration())
    print("Default Value: %.2f" % (def_value))

    bo = BayesianOptimization(objective_function, cs, max_runs=50, time_limit_per_trial=150)
    bo.run()
    inc_value = bo.get_incumbent()
    config = inc_value[0][0]

    with open(meta_dir + 'meta_learner_%s_%s_%s_config.pkl' % (meta_algo, metric, hash_id), 'wb') as f:
        pk.dump(config, f)
    print('Best hyperparameter config found', config)
    return config
예제 #3
0
def test_branin():
    space_dict = {
        "parameters": {
            "x1": {
                "type": "float",
                "bound": [-5, 10],
                "default": 0
            },
            "x2": {
                "type": "float",
                "bound": [0, 15]
            },
        }
    }

    cs = get_config_space_from_dict(space_dict)
    print(cs)

    bo = BayesianOptimization(branin,
                              cs,
                              max_runs=30,
                              time_limit_per_trial=3,
                              logging_dir='logs')
    bo.run()
    inc_value = bo.get_incumbent()
    print('BO', '=' * 30)
    print(inc_value)

    # Evaluate the random search.
    bo = BayesianOptimization(branin,
                              cs,
                              max_runs=30,
                              time_limit_per_trial=3,
                              sample_strategy='random',
                              logging_dir='logs')
    bo.run()
    inc_value = bo.get_incumbent()
    print('RANDOM', '=' * 30)
    print(inc_value)

    # Evaluate batch BO.
    bo = BatchBayesianOptimization(branin,
                                   cs,
                                   max_runs=10,
                                   batch_size=3,
                                   time_limit_per_trial=3,
                                   sample_strategy='median_imputation',
                                   logging_dir='logs')
    bo.run()
    inc_value = bo.get_incumbent()
    print('MEDIAN IMPUTATION BATCH BO', '=' * 30)
    print(inc_value)

    # Evaluate batch BO.
    bo = BatchBayesianOptimization(branin,
                                   cs,
                                   max_runs=10,
                                   batch_size=3,
                                   time_limit_per_trial=3,
                                   sample_strategy='local_penalization',
                                   logging_dir='logs')
    bo.run()
    inc_value = bo.get_incumbent()
    print('LOCAL PENALIZATION BATCH BO', '=' * 30)
    print(inc_value)
예제 #4
0
            "bound": [0, 15]
        },
    }
}

from litebo.utils.config_space.space_utils import get_config_space_from_dict
cs = get_config_space_from_dict(space_dict)
print(cs)

bo = BayesianOptimization(branin,
                          cs,
                          max_runs=90,
                          time_limit_per_trial=3,
                          logging_dir='logs')
bo.run()
inc_value = bo.get_incumbent()
print('BO', '=' * 30)
print(inc_value)

# Evaluate the random search.
bo = BayesianOptimization(branin,
                          cs,
                          max_runs=90,
                          time_limit_per_trial=3,
                          sample_strategy='random',
                          logging_dir='logs')
bo.run()
inc_value = bo.get_incumbent()
print('RANDOM', '=' * 30)
print(inc_value)