Hi,
Thank you for a great work!
I have a question.
Sometimes we need to define search space for several classifiers.
They may have some common parameter like l1, dropout, etc.
Is it possible to define subspaces in some way to avoid DuplicateLabel exception?
How to reproduce: https://stackoverflow.com/questions/48386740/hyperopt-defining-search-space (not mine but the same issue) - it has a solution but this solution may not work in some cases (a lot of parameters, dozens of classifiers and so on).
you should only modify the label in stochastic expressions, such as:
# this will raise DuplicateLabel Exception
space = hp.choice('space', [
{'x1': hp.choice('x', [1,2,3)},
{'x2': hp.choice('x', [1,2,3)}]
# to correct it, i think the best modification is:
space = hp.choice('space', [
{'x1': hp.choice('x1-x', [1,2,3)},
{'x2': hp.choice('x2-x', [1,2,3)}]
Hi,
I've got the same issue, I'm currently using sklearn pipeline that has an undersample and oversample steps, however, the hierarchical steps have the same parameter namespace.
space = {
'xgb': {
'learning_rate': hp.choice('learning_rate', np.arange(0.05, 0.2, 0.05,dtype=float)),
'max_depth': hp.choice('max_depth', np.arange(1, 4, 1, dtype=int)),
'gamma': hp.choice('gamma', np.arange(0.5, 2, 0.5, dtype=float)),
'n_estimators': hp.choice('n_estimators', np.arange(10, 40, 10,dtype=int)),
'nthread': hp.choice('nthread',[4]) ,
'seed': hp.choice('seed',[SEED])
},
'over': {
'sampling_strategy':hp.choice('sampling_strategy',[0.5]),
'k_neighbors': hp.choice('k_neighbors',[5]),
'random_state': hp.choice('random_state',[SEED])
},
'under': {
'sampling_strategy':hp.choice('sampling_strategy',[0.7]),
'random_state': hp.choice('random_state',[SEED])
}
}
@makquel is there a reason why you can't just give them unique labels? The label does not have to match the key in the dictionary.
The standard way of picking the labels in your case would be something like this:
'over': {
'sampling_strategy':hp.choice('over.sampling_strategy',[0.5]),
'k_neighbors': hp.choice('over.k_neighbors',[5]),
'random_state': hp.choice('over.random_state',[SEED])
},
'under': {
'sampling_strategy':hp.choice('under.sampling_strategy',[0.7]),
'random_state': hp.choice('under.random_state',[SEED])
}
@bjkomer thanks for the heads-up I realized that after posting the issue. I thought that it has to match exactly the step's parameter namespace after all.
Furthermore, I think we could close this issue though.
Most helpful comment
you should only modify the label in stochastic expressions, such as: