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

[Question/Issue] Choice parameters don't work with string values #93

Closed
Irynei opened this issue May 15, 2019 · 3 comments
Closed

[Question/Issue] Choice parameters don't work with string values #93

Irynei opened this issue May 15, 2019 · 3 comments
Labels
bug Something isn't working fixready Fix has landed on master.

Comments

@Irynei
Copy link

Irynei commented May 15, 2019

I was trying to do optimization using choice parameters. Here is a simple example:

best_parameters, values, experiment, model = optimize(
    parameters=[
        {'name': 'categorical', 'type': 'choice', 'values': ['foo', 'bar']}
    ],
    evaluation_function=objective,
    minimize=True,
)

And I got the following error:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ax/service/managed_loop.py", line 206, in optimize
loop.full_run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ax/service/managed_loop.py", line 150, in full_run
self.run_trial()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ax/service/managed_loop.py", line 130, in run_trial
experiment=self.experiment, new_data=dat
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ax/core/experiment.py", line 446, in new_trial
experiment=self, trial_type=trial_type, generator_run=generator_run
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ax/core/trial.py", line 38, in init
self.add_generator_run(generator_run=generator_run)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ax/core/base_trial.py", line 85, in _immutable_once_run
return func(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ax/core/trial.py", line 87, in add_generator_run
generator_run.arms[0].parameters, raise_error=True
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ax/core/search_space.py", line 192, in check_types
f"{value} is not a valid value for "
ValueError: bar is not a valid value for parameter ChoiceParameter(name='categorical', parameter_type=STRING, values=['foo', 'bar'])

Digging into that, I found that the problem was with the one_hot transformer, it changed the type of string values to numpy.str_ and hence, the ValueError was raised.

I see that this is already fixed in this commit, but it's not available in the currently latest 0.1.1 tag.

Could you please provide information when the new release is going to be?
Thank you!

@ldworkin
Copy link
Contributor

Hi @Irynei! I think we're planning to do a new release tomorrow :) In the meantime (or in the future) you can try pulling from master and then doing pip install -e ..

@ldworkin ldworkin added bug Something isn't working fixready Fix has landed on master. labels May 15, 2019
@Irynei
Copy link
Author

Irynei commented May 15, 2019

Cool, thanks.

@ldworkin
Copy link
Contributor

Closing, since this should be in our current release (0.1.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixready Fix has landed on master.
Projects
None yet
Development

No branches or pull requests

2 participants