Skip to main content

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

Metadata

Release files for mab-forge 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mab-forge 0.1.0
File Size Uploaded
mab_forge-0.1.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mab-forge 0.1.0
File Interpreter ABI Platform
mab_forge-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 kB

Release files / mab_forge-0.1.0.tar.gz

Download URL mab_forge-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d849b045e5ed07ef66a4ea679409d552642142836fce8a20bbbe069eaeac4ef8
BLAKE2b-256 checksum
How to use checksums
0c8ef7cd0b06377be1278c25735c0fa2887f30d5816bdcbf04320008c7924ef5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.6 Linux/5.15.167.4-microsoft-standard-WSL2

Release files / mab_forge-0.1.0-py3-none-any.whl

Download URL mab_forge-0.1.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f2e55a3ae36258bbce7bd8594852c963dbc8d32504aa63785936400dc812580
BLAKE2b-256 checksum
How to use checksums
a4698fa3ad7051869193e6a228229f6f3b33450e14bddebd402ccd2dd2de1f86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.11.6 Linux/5.15.167.4-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page