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

Upgrade to support python3 and matplotlib 3.8.2 #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def plot_results(solvers, solver_names, figname):

# Sub.fig. 3: Action counts
for s in solvers:
ax3.plot(range(b.n), np.array(s.counts) / float(len(solvers[0].regrets)), ls='steps', lw=2)
ax3.plot(range(b.n), np.array(s.counts) / float(len(solvers[0].regrets)), ls='-', lw=2)
ax3.set_xlabel('Actions')
ax3.set_ylabel('Frac. # trials')
ax3.grid('k', ls='--', alpha=0.3)
Expand All @@ -64,14 +64,13 @@ def experiment(K, N):
each with a randomly initialized reward probability.

Args:
K (int): number of slot machiens.
K (int): number of slot machines.
N (int): number of time steps to try.
"""

b = BernoulliBandit(K)
print "Randomly generated Bernoulli bandit has reward probabilities:\n", b.probas
print "The best machine has index: {} and proba: {}".format(
max(range(K), key=lambda i: b.probas[i]), max(b.probas))
print("Randomly generated Bernoulli bandit has reward probabilities:\n", b.probas)
print("The best machine has index: {} and proba: {}".format(max(range(K), key=lambda i: b.probas[i]), max(b.probas)))

test_solvers = [
# EpsilonGreedy(b, 0),
Expand Down