Skip to main content

Toolset for generating Multi-Armed Bandit problems according to a user-defined difficulty

Project description

Static Badge Static Badge

MAB Forge

Designing algorithms for Multi Armed Bandit problems involves working on their numerical assessment. However, the conditions such algorithms are tested is fundamental for drawing correct conclusions.

This repository provides an algorithm for controlling the biases when generating bandits for evaluation.

Installation

pip install mab-forge

Library

To create a new MAB with difficulty level 2.4, simply do

import mab_forge

mu, std = mab_forge.new_mab(n_arms=3, d_target=2.4)

To better grap on the intuitions of what the difficulty means, check out our paper and other provided materials.

Besides, we also provide a method for normalizing bandits to their semi-unit circle representation. Please, refer to the paper and other materials for better understanding normalization.

import numpy as np

import mab_forge

mu = np.array([1., 3., 5.])
std = np.array([0.3, 7., 10.])

norm_mu, norm_std = mab_forge.normalize(mu, std)

Lastly, you can compute the minimum exploration regret for any bandit problem given a confidence level and a maximum number of steps with

import numpy as np

import mab_forge

mu = np.array([1., 3., 5.])
std = np.array([0.3, 7., 10.])

# When using min_regret, you have to provide the optimal arm at the first index.
idx = np.argsort(mu)[::-1]
mu = mu[idx]
std = std[idx]

regret = mab_forge.min_regret(mu, std, T=2000, z=2.96)

print(regret)
# message: Optimization terminated successfully
# success: True
#  status: 0
#     fun: 523.6313564965296
#       x: [ 2.578e+02  2.000e+00]
#     nit: 15
#     jac: [ 2.000e+00  4.000e+00]
#    nfev: 50
#    njev: 14

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

mab_forge-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

mab_forge-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mab_forge-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.6 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for mab_forge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d849b045e5ed07ef66a4ea679409d552642142836fce8a20bbbe069eaeac4ef8
MD5 0e93a221eaacdc87f734cba8ad0497d3
BLAKE2b-256 0c8ef7cd0b06377be1278c25735c0fa2887f30d5816bdcbf04320008c7924ef5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mab_forge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.6 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for mab_forge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f2e55a3ae36258bbce7bd8594852c963dbc8d32504aa63785936400dc812580
MD5 a1ec5b65e163e87e3ee9a0c92fe4fedb
BLAKE2b-256 a4698fa3ad7051869193e6a228229f6f3b33450e14bddebd402ccd2dd2de1f86

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