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

Multi-Armed Bandit #343

Merged
merged 74 commits into from
Sep 6, 2024

Conversation

julianStreibel
Copy link
Collaborator

@julianStreibel julianStreibel commented Aug 14, 2024

This PR enables bandit models by bringing the following new features:

  • a class for modeling binary targets
  • a Beta-Bernoulli multi-armed bandit surrogate class
  • a Thompson sampling acquisition function (should be turned into a recommender in the future)
  • a beta prior
  • a bandit optimization example
  • the necessary torch infrastructure, such sampler for torch's beta distribution

@AVHopp
Copy link
Collaborator

AVHopp commented Aug 15, 2024

@AdrianSosic @julianStreibel is this already ready for review or do the two of you want to do a first round of review first?

@AdrianSosic
Copy link
Collaborator

@AdrianSosic @julianStreibel is this already ready for review or do the two of you want to do a first round of review first?

Hi @AVHopp, I'll do a first iteration 👍🏼

@AdrianSosic AdrianSosic force-pushed the feature/multi_armed_bandit branch 2 times, most recently from 5ffd6df to 3fe605f Compare August 16, 2024 13:50
Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @julianStreibel, thanks so much for this very nice PR. I'm already in the middle of the review/code roast and will continue on Monday. But here already a few things where I need input / that we need to discuss. See ya next week 😎

baybe/recommenders/pure/base.py Outdated Show resolved Hide resolved
baybe/surrogates/multi_armed_bandit.py Outdated Show resolved Hide resolved
examples/Multi_Armed_Bandit/multi_armed_bandit.py Outdated Show resolved Hide resolved
@AdrianSosic AdrianSosic self-assigned this Aug 21, 2024
@AdrianSosic AdrianSosic added the new feature New functionality label Aug 21, 2024
Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here my open points

baybe/priors/basic.py Show resolved Hide resolved
baybe/targets/binary.py Outdated Show resolved Hide resolved
baybe/acquisition/acqfs.py Show resolved Hide resolved
baybe/surrogates/bandit.py Show resolved Hide resolved
baybe/surrogates/bandit.py Show resolved Hide resolved
@Scienfitz
Copy link
Collaborator

the target branch for this PR is not main but dev/surrogates, which however is in the process of being completed/merged. Is this intended?

@AdrianSosic AdrianSosic changed the base branch from dev/surrogates to main August 28, 2024 10:58
@AdrianSosic
Copy link
Collaborator

the target branch for this PR is not main but dev/surrogates, which however is in the process of being completed/merged. Is this intended?

No, that was done by @julianStreibel, probably because the two of haven't talked about where this is supposed to go. Have change it now. Once the dev branch is merged, I'll rebase

Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here same comment as thread so that we can discuss.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@Scienfitz Scienfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey guys @julianStreibel @AdrianSosic this is fantastic and I love the example - thanks a lot. I might need another round since this is a lot of code, but I'll leave a first round of comments and stupid questions

README.md Outdated Show resolved Hide resolved
baybe/acquisition/base.py Show resolved Hide resolved
baybe/priors/basic.py Show resolved Hide resolved
baybe/recommenders/base.py Show resolved Hide resolved
baybe/recommenders/pure/base.py Show resolved Hide resolved
baybe/acquisition/acqfs.py Show resolved Hide resolved
baybe/surrogates/bandit.py Show resolved Hide resolved
baybe/surrogates/bandit.py Outdated Show resolved Hide resolved
baybe/surrogates/bandit.py Show resolved Hide resolved
Copy link
Collaborator

@AVHopp AVHopp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this epic piece of work :) My main issue is the example which I think is too complex, see the individual comments.

baybe/acquisition/acqfs.py Show resolved Hide resolved
baybe/acquisition/base.py Show resolved Hide resolved
baybe/surrogates/bandit.py Show resolved Hide resolved
baybe/priors/basic.py Show resolved Hide resolved
baybe/priors/basic.py Show resolved Hide resolved
tests/hypothesis_strategies/kernels.py Show resolved Hide resolved
baybe/surrogates/bandit.py Show resolved Hide resolved
@AdrianSosic AdrianSosic force-pushed the feature/multi_armed_bandit branch 2 times, most recently from 8e1837a to b98b074 Compare September 5, 2024 20:09
Copy link
Collaborator

@AVHopp AVHopp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve to unblock

AdrianSosic and others added 17 commits September 6, 2024 12:06
Switch from positive/negative to success/failure
Switch from True/False to 1.0/0.0
* The normalization factor of the Frobenius norm was wrong. Should have
  been divided by number of Monte Carlos instead of number of arms.
* Computation via bias-variance decomposition is more suggestive.
* Avoids to set the allow_* flags in the RandomRecommender since each
  run gets a fresh search space instance with untouched metadata
* Added comment on remaining necessary flags
Otherwise causes a lot of problems because nan!=nan
@AdrianSosic AdrianSosic merged commit 99f5e9e into emdgroup:main Sep 6, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants