Skip to main content
# pybayesbandit

Bayesian bandits in Python3.

## Quickstart

```text
$ pip install pybayesbandit
```

## Usage

```text
$ pybayesbandit --help
usage: pybayesbandit [-h] [-p PARAMS [PARAMS ...]] [-d MAXDEPTH] [-t TRIALS]
[-C C] [-e EPISODES] [-hr HORIZON] [--plot] [-v]
{random,ucb,thompson,vi,uct,rollout,aotree} {bernoulli}
{total,simple}

Bayesian bandits in Python3.

positional arguments:
{random,ucb,thompson,vi,uct,rollout,aotree}
learner type
{bernoulli} bandit type
{total,simple} game setting

optional arguments:
-h, --help show this help message and exit
-p PARAMS [PARAMS ...], --params PARAMS [PARAMS ...]
bandit parameters
-d MAXDEPTH, --maxdepth MAXDEPTH
maximum number of timesteps in the tree lookahead
(default=10)
-t TRIALS, --trials TRIALS
number of trials in Monte-Carlo sampling (default=30)
-C C UCT exploration constant (default=2.0)
-e EPISODES, --episodes EPISODES
number of simulation episodes (default=200)
-hr HORIZON, --horizon HORIZON
number of timesteps in each episode (default=100)
--plot plot cumulative regret
-v, --verbose verbose mode
```

## Examples

```text
$ pybayesbandit ucb bernoulli total -p 0.5 0.8 0.3 -e 100 -hr 50 -v

Running pybayesbandit ...
>> learner = ucb
>> bandit = bernoulli([0.5, 0.8, 0.3])
>> episodes = 100
>> horizon = 50
Done in 0.257 sec.

Results:
>> Reward = 32.3900 ± 3.4173
>> Regret = 7.6530 ± 1.7081
```

```text
$ pybayesbandit thompson bernoulli total -p 0.5 0.8 0.3 -e 100 -hr 50 -v

Running pybayesbandit ...
>> learner = thompson
>> bandit = bernoulli([0.5, 0.8, 0.3])
>> episodes = 100
>> horizon = 50
Done in 0.297 sec.

Results:
>> Reward = 35.2200 ± 3.8822
>> Regret = 4.4560 ± 2.6086
```

```text
$ pybayesbandit uct bernoulli total -p 0.5 0.8 0.3 -e 100 -hr 50 --trials 15 --maxdepth 5 -v

Running pybayesbandit ...
>> learner = uct(trials=15, maxdepth=5, C=2.0)
>> bandit = bernoulli([0.5, 0.8, 0.3])
>> episodes = 100
>> horizon = 50
Done in 7.066 sec.

Results:
>> Reward = 36.2800 ± 5.4828
>> Regret = 3.4360 ± 4.5856
```

## License

Copyright (c) 2018 Thiago Pereira Bueno All Rights Reserved.

pybayesbandit is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

pybayesbandit is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with pybayesbandit. If not, see http://www.gnu.org/licenses/.

Metadata

Release files for pybayesbandit 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybayesbandit 0.0.4
File Size Uploaded Provenance
pybayesbandit-0.0.4.tar.gz 10.0 kB Without provenance Details

Release files / pybayesbandit-0.0.4.tar.gz

Download URL pybayesbandit-0.0.4.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4fd07382e1d3fb997f2c13a69a6dbad1b4f3d55025617437012298b8bc6fed08
BLAKE2b-256 checksum
How to use checksums
7be9f8a51af72b57ef2802fdf8b5ad5ab2856f9272dd414429986204b04a18ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Security for pybayesbandit 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page