Skip to main content

A modular library for multi-armed bandit algorithms

Project description

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

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

rl_bandits-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rl_bandits-0.1.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file rl_bandits-0.1.0.tar.gz.

File metadata

  • Download URL: rl_bandits-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for rl_bandits-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ecbaf5c57ec37a3bc95c752d85301c5048ff6663ead048c1bb29f1329b3a7e10
MD5 6c638f7b7858f32cc9201f8057c55485
BLAKE2b-256 412b651385741b99686cadac316bf7a8a8825ff12346991e50082446c57cd6f4

See more details on using hashes here.

File details

Details for the file rl_bandits-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rl_bandits-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for rl_bandits-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e45d754a59b6953d23e74109969081279b26f6aae2dc6cfce4c5f39c9b8e867
MD5 a13551c9b35706855d344ceb36ec4c1f
BLAKE2b-256 d050503321e5bb97845a87ce39a48de2f663fa8f11731661f9cfdd9f144d786b

See more details on using hashes here.

Supported by

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