A multi-armed bandit (MAB) simulation library
Project description
mabby is a library for simulating multi-armed bandits (MABs), a resource-allocation problem and framework in reinforcement learning. It allows users to quickly yet flexibly define and run bandit simulations, with the ability to:
- choose from a wide range of classic bandit algorithms to use
- configure environments with custom arm spaces and rewards distributions
- collect and visualize simulation metrics like regret and optimality
Installation
Prerequisites: Python 3.9+ and pip
Install mabby with pip
:
pip install mabby
Basic Usage
The code example below demonstrates the basic steps of running a simulation with mabby. For more in-depth examples, please see the Usage Examples section of the mabby documentation.
import mabby as mb
# configure bandit arms
bandit = mb.BernoulliArm.bandit(p=[0.3, 0.6])
# configure bandit strategy
strategy = mb.strategies.EpsilonGreedyStrategy(eps=0.2)
# setup simulation
simulation = mb.Simulation(bandit=bandit, strategies=[strategy])
# run simulation
stats = simulation.run(trials=100, steps=300)
# plot regret statistics
stats.plot_regret()
Contributing
Please see CONTRIBUTING for more information.
License
This software is licensed under the Apache 2.0 license. Please see LICENSE for more information.
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
Built Distribution
File details
Details for the file mabby-0.1.2.tar.gz
.
File metadata
- Download URL: mabby-0.1.2.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.9.13 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f40835eed6af465285f38b21df060f53191a08c388898646c232deacaf252d5 |
|
MD5 | 55932e953cfa11913fcfc1b53b737741 |
|
BLAKE2b-256 | d791e2eaad9eaf64b1af0e6cd5f5c47f159babb8f481a849a9f15f3e36270084 |
File details
Details for the file mabby-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: mabby-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.9.13 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f7b22299558087cf4c0e724e4f1c1328dfb2f785530380df5cc6e4119c75526 |
|
MD5 | 69c4a3887a02db78e9cc97b1525891c1 |
|
BLAKE2b-256 | de5dc0b1f334c8dc1125d67d8f115643b06bac2597948d04d92767242a34137e |