Multi-Arm-Bandit library
Project description
Build Status
pulpo
A library and sdk for non-contextual and contextual Multi-Armed-Bandit (MAB) algorithms for multiple use cases. The sdk version enables you to deploy it on AWS.
Installation
Prerequisites
pulpo requires Python 3.6+
Install pulpo
At the command line:
pip install pulpo
How To
Library
Pulpo can be used as a library to instantiate and run online MABs. The core of the library are the bandit implementations under pulpo/badnits
module. The super class of them is OnlineBandit
if you wish to implement your own MAB implementation.
Currently, the following MAB implementations are available:
- Epsilon Greedy (
EGreedy
)
The usage of this library starts from Pulpo
class. For example, let's say that we want to run 1 online bandit with 3 arms using EGreedy
, then:
from pulpo.bandits.dataclasses import EpsilonGreedyArm
from pulpo.bandits.epsilon_greedy import EGreedy
from pulpo.pulpo import Pulpo
arm_names = ["article1", "article2", "article3"]
arms = [EpsilonGreedyArm(name, 1, 0) for name in arm_names] # priors for n=1 and sum=0, i.e. steps and total reward so far
bandit = EGreedy("article_recommendation", arms, epsilon=0.9)
pulpo = Pulpo([bandit]) # Instantiate Pulpo
arm_id = pulpo.choose(bandit.bandit_id) # to get an arm decision
# get some feedback for the arm decision and pass it to back
feedback = 1.0
pulpo.update(bandit.bandit_id, arm_id, feedback)
Alternatively, the Pulpo
class can be instantiated in the following manner:
import json
from pulpo.pulpo import Pulpo
bandit_id = "article_recommendation"
config = config = [{"bandit_id": bandit_id, "bandit_type": "epsilon_greedy", "arm_ids": ["article1", "article2", "article3"]}]
pulpo = Pulpo.make_from_json(json.dumps(config)) # Instantiate Pulpo
arm_id = pulpo.choose(bandit_id) # to get an arm decision
# get some feedback for the arm decision and pass it to back
feedback = 1.0
pulpo.update(bandit_id, arm_id, feedback)
AWS SDK
Pulpo can be used as an sdk to deploy and run MABs on AWS. Soon...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pulpo-0.0.1.tar.gz
.
File metadata
- Download URL: pulpo-0.0.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c903c22c25e47f88b91e1710a1ff516d5b2d8bb10f7ad159ed85a3542401be6b |
|
MD5 | b9fe79326e8c659e7f0d50960ef49348 |
|
BLAKE2b-256 | ddda105c2d5795a1d28a38e0fbec6d146d7a68a324c9a2b0f8f827e7d791fdae |