Dueling Bandit Toolkit
The Dueling Bandit Toolkit is a Python package designed for preference-based online learning using dueling bandit algorithms. It provides robust implementations of state-of-the-art algorithms, support for real-world datasets, and comprehensive evaluation metrics, making it an ideal tool for researchers and practitioners in machine learning and decision-making systems.
Features
- Algorithms: Includes Double Thompson Sampling, PARWiS, Contextual PARWiS, and a Random Pair baseline.
- Environment: Supports the Bradley-Terry model with optional contextual features for flexible experimentation.
- Datasets: Compatible with synthetic data and real-world datasets like Jester and MovieLens.
- Metrics: Evaluates performance with cumulative regret, recovery fraction, true/reported ranks, and separation (Δ₁,₂).
- Visualization: Offers plotting functions to visualize experiment results using Matplotlib.
Installation
Install the package via pip from PyPI:
pip install dueling-bandit
Ensure you have Python 3.8 or higher.
Quick Start
Here's a simple example to get started with the toolkit:
from dueling_bandit.environment import DuelingBanditEnv
from dueling_bandit.agents import DoubleThompsonSamplingAgent
from dueling_bandit.experiments import run_simulation
from dueling_bandit.plotting import plot_metric
# Create a synthetic Bradley-Terry environment
env = DuelingBanditEnv.random_bt(k=20, d=5, seed=42)
# Initialize the Double Thompson Sampling agent
agent = DoubleThompsonSamplingAgent(k=20, seed=42)
# Run a simulation for 500 duels
results = run_simulation(env, agent, horizon=500)
# Visualize the cumulative regret
plot_metric({'500': {'Double TS': results}}, budget=500, dataset='synthetic', metric='mean_regret')
This code sets up a synthetic environment, runs a simulation with the Double Thompson Sampling algorithm, and plots the cumulative regret.
Requirements
- Python >= 3.8
- Dependencies:
numpy,matplotlib,scipy,pandas
Install all dependencies:
pip install -r requirements.txt
Development
To contribute or experiment with the toolkit:
- Clone the repository:
git clone https://github.com/shailendrabhandari/dueling_bandit.git cd dueling_bandit
- Install in editable mode:
pip install -e .
- Run tests to ensure everything works:
pytest tests/
Documentation
Comprehensive documentation is available at ReadTheDocs. It includes detailed API references, tutorials, and examples to help you get the most out of the toolkit.
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Whether it's bug fixes, new features, or documentation improvements, please:
- Open an issue to discuss your idea.
- Submit a pull request with your changes.
See the Contributing Guidelines for more details.
Contact
For questions or support, please open an issue on GitHub or contact Shailendra at shailendra.bhandari@oslomet.no.
Happy dueling!
Metadata
Release files for dueling-bandit 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dueling_bandit-0.1.2.tar.gz | 11.9 kB | Without provenance | Details for dueling_bandit-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dueling_bandit-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for dueling_bandit-0.1.2-py3-none-any.whl |
Total release size: 23.5 kB
Release files / dueling_bandit-0.1.2.tar.gz
| Download URL | dueling_bandit-0.1.2.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a56fff9481358c862cbc2304acc446c7d40fb09dd1ce7e7d36070b48f74947bd
|
|
BLAKE2b-256 checksum How to use checksums |
11804616050044546ae6cc823ce19fe7011fa6a25068311c8b0233e81b7eeb7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Release files / dueling_bandit-0.1.2-py3-none-any.whl
| Download URL | dueling_bandit-0.1.2-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef034cbfb14296a4c1a1bd034b7f13dad3200b9d04f4a5b8bb163b80ca1a346a
|
|
BLAKE2b-256 checksum How to use checksums |
edb9ebd52d8f276f3c7ba149b7219385bd6f47d1b597d8af12ec56669baa4953
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Security for dueling-bandit 0.1.2
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.