Skip to main content

No project description provided

Project description

bayesianbandits

bayesianbandits is a Pythonic framework for building agents to maximize rewards in multi-armed bandit (MAB) problems. These agents can handle a number of MAB subproblems, such as contextual, restless, and delayed reward bandits.

Building an agent is as simple as defining arms and using the necessary decorators. For example, to create an agent for a Bernoulli bandit:

import numpy as np

from bayesianbandits import Bandit, Arm, epsilon_greedy, DirichletClassifier

def reward_func(x):
    return np.take(x, 0, axis=-1)

clf = DirichletClassifier({"yes": 1.0, "no": 1.0})
policy = epsilon_greedy(0.1)

class Agent(Bandit, learner=clf, policy=policy):
    arm1 = Arm("action 1", reward_func)
    arm2 = Arm("action 2", reward_func)

agent = Agent()

agent.pull() # receive some reward
agent.update("yes") # update with observed reward

Getting Started

Install this package from PyPI.

pip install -U bayesianbandits

Usage

Check out the documentation for examples and an API reference.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bayesianbandits-0.3.0.tar.gz (16.1 kB view hashes)

Uploaded Source

Built Distribution

bayesianbandits-0.3.0-py3-none-any.whl (18.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page