WillKoehrsen/hyperparameter-optimization

issues with nested data structure in `space`

scigeek72 opened this issue · 0 comments

Hi,
I am following your implementation of hyper-parameter optimization of GBR (in my case). I am getting error when I define a space with nested data structure.

space = {
    'boosting_type': hp.choice('boosting_type', 
                                            [{'boosting_type': 'gbdt', 'subsample': hp.uniform('gbdt_subsample', 0.5, 1)}, 
                                             {'boosting_type': 'dart', 'subsample': hp.uniform('dart_subsample', 0.5, 1)},
                                             {'boosting_type': 'goss', 'subsample': 1.0}]),
    'num_leaves': hp.quniform('num_leaves', 30, 150, 1),
    'learning_rate': hp.loguniform('learning_rate', np.log(0.01), np.log(0.2)),
    'subsample_for_bin': hp.quniform('subsample_for_bin', 20000, 300000, 20000),
    'min_child_samples': hp.quniform('min_child_samples', 20, 500, 5),
    'reg_alpha': hp.uniform('reg_alpha', 0.0, 1.0),
    'reg_lambda': hp.uniform('reg_lambda', 0.0, 1.0),
    'colsample_bytree': hp.uniform('colsample_by_tree', 0.6, 1.0),
    'objective': ['regression']
}

When I run

best = fmin(fn=objective, space= space, algo=tpe_algorithm, max_evals=MAX_EVAL, trials=bayes_trials, rstate=np.random.RandomState(50))

I am getting the following error: (I am pasting only the final error comments rather than the entire Trace which is rather long).

----> 5 best = fmin(fn=objective, space= space, algo=tpe_algorithm, max_evals=MAX_EVAL, trials=bayes_trials, rstate=np.random.RandomState(50))
...
...
TypeError: Unknown type of parameter:boosting_type, got:dict

Any advice will be of value to me.

Thanks