RL Bandits
A modular Python library for multi-armed bandit algorithms, designed for research and experimentation.
Features
- Environments: Stationary and non-stationary k-armed bandits
- Agents: ε-greedy, UCB, gradient bandit algorithms
- Evaluation: Single and multi-run experiment framework
- Utilities: Plotting, seeding, and configuration management
Installation
# Clone the repository
git clone https://github.com/meeran03/rl-bandits.git
cd rl-bandits
# Install in development mode
pip install -e .
# Or install with development dependencies
pip install -e ".[dev]"
Quick Start
from rlbandits import Bandit, EpsilonGreedyAgent, run_multi_experiment, plot_curves
# Create environment and agent
bandit_kwargs = {"k": 10, "reward_std": 1.0}
agent = EpsilonGreedyAgent(k=10, epsilon=0.1)
# Run experiment
results = run_multi_experiment(
bandit_class=Bandit,
bandit_kwargs=bandit_kwargs,
agent=agent,
steps=1000,
runs=200
)
# Plot results
plot_curves(results, title="ε-Greedy Performance")
Project Structure
rl-bandits/
├── README.md
├── pyproject.toml
├── requirements.txt
├── rlbandits/
│ ├── __init__.py
│ ├── envs/ # Bandit environments
│ │ ├── stationary_bandit.py
│ │ └── nonstationary_bandit.py
│ ├── agents/ # Bandit algorithms
│ │ ├── epsilon_greedy.py
│ │ ├── ucb.py
│ │ └── gradient_bandit.py
│ ├── core/ # Experiment framework
│ │ ├── runner.py
│ │ ├── eval.py
│ │ └── utils.py
│ └── experiments/ # Configuration files
├── notebooks/ # Jupyter notebooks
├── tests/ # Unit tests
└── .github/workflows/ # CI/CD
Algorithms Implemented
- Greedy: Pure greedy action selection
- ε-Greedy: Epsilon-greedy with exploration
- UCB: Upper Confidence Bound
- Gradient Bandit: Preference-based policy gradient
Development
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black rlbandits/ tests/
# Type checking
mypy rlbandits/
License
MIT License
Metadata
Release files for rl-bandits 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rl_bandits-0.1.0.tar.gz | 14.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rl_bandits-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.5 kB
Release files / rl_bandits-0.1.0.tar.gz
| Download URL | rl_bandits-0.1.0.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecbaf5c57ec37a3bc95c752d85301c5048ff6663ead048c1bb29f1329b3a7e10
|
|
BLAKE2b-256 checksum How to use checksums |
412b651385741b99686cadac316bf7a8a8825ff12346991e50082446c57cd6f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.10
|
Release files / rl_bandits-0.1.0-py3-none-any.whl
| Download URL | rl_bandits-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e45d754a59b6953d23e74109969081279b26f6aae2dc6cfce4c5f39c9b8e867
|
|
BLAKE2b-256 checksum How to use checksums |
d050503321e5bb97845a87ce39a48de2f663fa8f11731661f9cfdd9f144d786b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.10
|