MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / plot_comparison

Function plot_comparison

numpy_ml/plots/bandit_plots.py:151–171  ·  view source on GitHub ↗

Use the BanditTrainer to compare several policies on the same bandit problem

()

Source from the content-addressed store, hash-verified

149
150
151def plot_comparison():
152 """
153 Use the BanditTrainer to compare several policies on the same bandit
154 problem
155 """
156 np.random.seed(1234)
157 ep_length = 1
158 K = 10
159
160 n_duplicates = 5
161 n_episodes = 5000
162
163 cmab = random_bernoulli_mab(n_arms=K)
164 policy1 = EpsilonGreedy(epsilon=0.05, ev_prior=0.5)
165 policy2 = UCB1(C=1, ev_prior=0.5)
166 policy3 = ThompsonSamplingBetaBinomial(alpha=1, beta=1)
167 policies = [policy1, policy2, policy3]
168
169 BanditTrainer().compare(
170 policies, cmab, ep_length, n_episodes, n_duplicates,
171 )

Callers

nothing calls this directly

Calls 6

EpsilonGreedyClass · 0.90
UCB1Class · 0.90
BanditTrainerClass · 0.90
random_bernoulli_mabFunction · 0.85
compareMethod · 0.80

Tested by

no test coverage detected