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

[Feature Request] Specifying fixed features to AxClient.get_next_trial (to conduct contextual BO using Service API) #746

Closed
MattiaVerticchio opened this issue Dec 7, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request wishlist Long-term wishlist feature requests

Comments

@MattiaVerticchio
Copy link

Hi everyone. First of all, thanks for working on Ax! 😁

I have a setting where I’d like to optimize a function based on a certain context. The context is, in this case, the day of the week.

If I understood correctly, the only way to have contextual BO in Ax is by using the Developer API; setting the context as input covariates, and then generating a new_trial with fixed_features:

gpei = Models.BOTORCH(
    experiment=exp,
    data=exp.fetch_data()
)

generator_run = gpei.gen(n=1)

fixed_features = ObservationFeatures(parameters={"day_of_week": 0})

trial = exp.new_trial(
    generator_run=generator_run,
    fixed_features=fixed_features)
)

For this kind of task, the Developer API is more flexible but adds a lot of complexity. Is there any other way to do contextual BO, or pass fixed_features when using the simpler Service API?

Thanks!

@lena-kashtelyan
Copy link
Contributor

Hi @MattiaVerticchio, I think right now the Service API does not support this case, but it definitely could –– it seems reasonable for get_next_trial to be able to accept fixed features. I'll mark this as a feature request!

In the meantime, you can hack around this like in this comment: #733 (comment), so basically generating the parameterizations outside of AxClient via Models.BOTORCH and then attaching them via attach_trial. Generally we really don't recommend this approach, but while the functionality you'd like isn't supported, you can make use of this perhaps?

@lena-kashtelyan lena-kashtelyan self-assigned this Dec 7, 2021
@lena-kashtelyan lena-kashtelyan added the enhancement New feature or request label Dec 7, 2021
@lena-kashtelyan lena-kashtelyan changed the title Contextual BO using Service API [Feature Request] Specifying fixed features to AxClient.get_next_trial (to conduct contextual BO using Service API) Dec 16, 2021
@MattiaVerticchio
Copy link
Author

In the meantime, you can hack around this like in this comment: #733 (comment), so basically generating the parameterizations outside of AxClient via Models.BOTORCH and then attaching them via attach_trial. Generally we really don't recommend this approach, but while the functionality you'd like isn't supported, you can make use of this perhaps?

Yes, that’s definitely better, thanks for your help!

@lena-kashtelyan
Copy link
Contributor

Putting this on wishlist for now, but we will likely support this soon!

@sgbaird
Copy link
Contributor

sgbaird commented Oct 30, 2022

@MattiaVerticchio, do you mind including a reproducer for this example if you have one available?

Cesar-Cardoso added a commit to Cesar-Cardoso/Ax that referenced this issue Apr 17, 2024
Summary:
Addresses facebook#746 (also in the wishlist facebook#566).

As the title implies, this PR adds the possibility of specifying some `FixedFeatures` as `fixed_features` in `AxClient.get_next_trial` and `AxClient.get_next_trials` which is currently only possible with the developer API.

Differential Revision: D56068035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wishlist Long-term wishlist feature requests
Projects
None yet
Development

No branches or pull requests

3 participants