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

cannot import name 'acquisition' from 'bayes_opt' #500

Closed
dinghly opened this issue Jul 16, 2024 · 4 comments
Closed

cannot import name 'acquisition' from 'bayes_opt' #500

dinghly opened this issue Jul 16, 2024 · 4 comments

Comments

@dinghly
Copy link

dinghly commented Jul 16, 2024

Hello, I am trying to reproduce the section exploitation vs exploration from https://bayesian-optimization.github.io/BayesianOptimization/exploitation_vs_exploration.html#Acquisition-Function-%22Upper-Confidence-Bound%22

I have installed bayesian optimization 1.5.1 and whenever I am trying to import acquisition by typing

from bayes_opt import acquisition,

it returns

ImportError: cannot import name 'acquisition' from 'bayes_opt' (C:\Users\ldhy9\AppData\Local\Programs\Python\Python311\Lib\site-packages\bayes_opt_init_.py)

can you help why?

thank you

@till-m
Copy link
Member

till-m commented Jul 16, 2024

Hi @dinghly,

you're very fast! We merged a PR recently that changed the acquisition function and docs are hosted based on master. However, we haven't pushed the release yet. The notebook for v1.5.1 can be found here. Hope that helps!

@dinghly
Copy link
Author

dinghly commented Jul 16, 2024

Thank you so much for your quick help!

@evancollins1
Copy link

evancollins1 commented Aug 15, 2024

Hi, I'm also having troubles with

from bayes_opt import acquisition

To clarify, are "utility" and "acquisition" functions referring to the same thing? Thus, would

acquisition_function = acquisition.ExpectedImprovement(xi=0.1)
be equivalent to
utility_function = UtilityFunction(kind="ei", xi=0.1)
???
(The latter one works and avoids this import issue)

Thanks

@till-m
Copy link
Member

till-m commented Aug 15, 2024

Hi @evancollins1,

In short, the code you describe shows how to do the exact same thing in different versions, so you can consider them conceptually the same.

To be more specific, the old way acquisition functions were implemented was somewhat inflexible and convoluted. This code has been overhauled and is what you can find on master. However, it's not yet released. As the code documentation online is based on what you can find on master (as of now, I'm working on this, see #509) you're seeing the code for the newer, yet to be released, version while probably using an older one.

I hope that clears up the confusion. Apologies for any inconveniences.

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

3 participants