Skip to main content

A toolkit for preference-based online learning with dueling bandits

Project description

Dueling Bandit Toolkit

A Python package for preference-based online learning with dueling bandits. This toolkit implements algorithms like Double Thompson Sampling, PARWiS, and Contextual PARWiS, with support for real-world datasets (Jester, MovieLens) and evaluation metrics. Features

Algorithms: Double Thompson Sampling, PARWiS, Contextual PARWiS, and Random Pair baseline. Environment: Bradley-Terry model with optional contextual features. Datasets: Synthetic, Jester, and MovieLens support. Metrics: Cumulative regret, recovery fraction, true/reported ranks, and separation (Δ_1,2). Visualization: Plotting functions for experiment results.

Installation pip install dueling-bandit

Usage from dueling_bandit.environment import DuelingBanditEnv from dueling_bandit.agents import DoubleThompsonSamplingAgentpython -m build from dueling_bandit.experiments import run_simulation

Create environment

env = DuelingBanditEnv.random_bt(k=20, d=5, seed=42)

Initialize agent

agent = DoubleThompsonSamplingAgent(k=20, seed=42)

Run simulation

results = run_simulation(env, agent, horizon=500)

Plot results (requires matplotlib)

from dueling_bandit.plotting import plot_metric plot_metric({'500': {'Double TS': results}}, budget=500, dataset='synthetic', metric='mean_regret')

Requirements

Python >= 3.8 numpy, matplotlib, scipy, pandas

Install dependencies: pip install -r requirements.txt

Development

Clone the repository:git clone https://github.com/shailendrabhandari/dueling_bandit.git cd dueling-bandit

Install in editable mode:pip install -e .

Run tests:pytest tests/

Documentation Full documentation is available at ReadTheDocs. License MIT License. See LICENSE for details. Contributing Contributions are welcome! Please open an issue or pull request on GitHub.

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

dueling_bandit-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

dueling_bandit-0.1.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dueling_bandit-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for dueling_bandit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6501d4dcdb4d1717f522d5f6f4c86d1ebced239893ba1b131b98c791d6933657
MD5 1f1ced15cc3956657e6e0ac579c17415
BLAKE2b-256 201b5ee1e29167f13cfd6067c307b930e04ccd561ffa51124e59bd7657f001d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dueling_bandit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for dueling_bandit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9cdd4858105305c69ba26a6d04edde0b3a5d65b0e51927752ee1b8134c17450
MD5 45ae474b77bbc57b4ad71eb638f82660
BLAKE2b-256 156a8a508496caab8ed1d7e7f7f2935071bebecf5be1c7b84d3d887811c33fb1

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