Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with categorical parameters #66

Open
ophiry opened this issue Jan 5, 2016 · 1 comment
Open

Issue with categorical parameters #66

ophiry opened this issue Jan 5, 2016 · 1 comment
Assignees

Comments

@ophiry
Copy link

ophiry commented Jan 5, 2016

also posted in stack overflow: http://stackoverflow.com/questions/34599726/strange-error-when-using-optunity-maximize-structured-with-discrete-parameters

I'm trying to use optunity (version 1.1.1) for hyperparameter optimization
When I'm trying to use categorical parameters in the optimization, I get a strange crash.

I assume I don't define the categorical parameter correctly, though I follow the documetation

Code Example:

import pprint
import optunity

search_params = {
    'algorithm': {'algo1':
                      {'float1': [3, 9],
                       'float2': [0.3, 1.0],
                       'enum': {'val1': None, 'val1': None},
                       },
                  'algo2':
                      {'float3': [0.05, 0.15],
                       'float4': [3, 15],
                       }
                  }
}


def score_model(**kwargs):
    pprint.pprint(kwargs)
    return 0


optunity.maximize_structured(score_model, search_space=search_params, num_evals=20)

Output:

{'algo1': None,
 'algorithm': 'algo2',
 'float1': None,
 'float2': None,
 'float3': 0.13896484375,
 'float4': 9.12890625}
{'': 'enum',
 'algorithm': 'algo1',
 'float1': 5.162109375,
 'float2': 0.8612304687499999,
 'float3': None,
 'float4': None}
{'algo1': None,
 'algorithm': 'algo2',
 'float1': None,
 'float2': None,
 'float3': 0.06708984375,
 'float4': 8.75390625}
{'': 'float2',
 'algorithm': 'algo1',
 'float1': 3.662109375,
 'float2': 0.33623046874999996,
 'float3': None,
 'float4': None}
{'algo1': None,
 'algorithm': 'algo2',
 'float1': None,
 'float2': None,
 'float3': 0.09208984375,
 'float4': 11.75390625}

Note that some of the objects seem OK, and some contain a blank key

Error Message

Traceback (most recent call last):
  File "C:/dev/git/the_lab/relevancy_models_for_dentsply/optimize_models_alt.py", line 23, in <module>
    optunity.maximize_structured(score_model, search_space=search_params, num_evals=5)
  File "C:\dev\venv\lib\site-packages\optunity\api.py", line 370, in maximize_structured
    pmap=pmap, decoder=tree.decode)
  File "C:\dev\venv\lib\site-packages\optunity\api.py", line 266, in optimize
    call_dict = f.call_log.to_dict()
  File "C:\dev\venv\lib\site-packages\optunity\functions.py", line 232, in to_dict
    args[key].append(value)
KeyError: ''
@claesenm claesenm self-assigned this Jan 5, 2016
@claesenm
Copy link
Owner

claesenm commented Jan 5, 2016

Thanks for reporting this problem, which at first glance seems to be an issue on our end, not yours. I will check this out ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants