Skip to content

Commit

Permalink
Merge: Speedup Bernoulli Multi-Armed Bandit Example (#380)
Browse files Browse the repository at this point in the history
This PR reduces the runtime of the Bernoulli multi-armed bandit example
from about 55 seconds to 7 seconds (in SMOKE_TEST setting) and sets a
random seed for reproducibility.

This is supposed to improve the displayed results in the example which
were unconverged and didnt show the discussed trend.
  • Loading branch information
Scienfitz authored Sep 22, 2024
2 parents 98a9383 + b49841a commit 26f699e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/Multi_Armed_Bandit/bernoulli_multi_armed_bandit.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
)
from baybe.surrogates import BetaBernoulliMultiArmedBanditSurrogate
from baybe.targets import BinaryTarget
from baybe.utils.random import set_random_seed

### An Imaginary Use Case

Expand Down Expand Up @@ -61,6 +62,10 @@ def draw_arm(self, arm_index: int) -> bool:

### Setup

# Setting a random seed for reproducibility.

set_random_seed(42)

# For our example, we use a system with a fixed collection of win rates, which we
# assume are unknown to us:

Expand All @@ -83,8 +88,8 @@ def draw_arm(self, arm_index: int) -> bool:
qThompsonSampling(), # Online optimization
PosteriorStandardDeviation(), # Active learning
]
N_MC_RUNS = 2 if SMOKE_TEST else 10
N_ITERATIONS = 2 if SMOKE_TEST else 200
N_MC_RUNS = 3 if SMOKE_TEST else 10
N_ITERATIONS = 50 if SMOKE_TEST else 200


### Building the Model
Expand Down

0 comments on commit 26f699e

Please sign in to comment.