Skip to main content

EXP4

A python implementation of Exponential weighting for Exploration and Exploitation with Experts. Based on this blog post.

This algorithm is useful for non-stochastic Contextual Multi Armed Bandits.

Build Status PyPI version License: MIT

Table of Contents

Installation

If you just need to use exp4, you can just run:

$ pip install exp4

For developers, note that this project uses the poetry python package/dependency management tool. Please familarize yourself with it and then run:

$ poetry install

Usage

exp4 is centered around the exp4.exp4 function which creates a co-routine for selecting arms given expert advice.

The protocol is as follows:

  1. The expert constructs an expert advice matrix.
    • Each row contains the corresponding experts advice vector.
    • The advice vector provides probabilities for each arm.
  2. The expert sends a tuple of loss and advice.
    • The loss corresponds to the previous round.
    • The first round's loss is ignored.
    • The advice correspond to the current round.

An example is given below.

from exp4 import exp4

player = exp4()

loss = None           # Will be ignored.
advice = [
    [1/3, 1/3, 1/3],  # Expert 1 
    [2/3, 1/3, 0],    # Expert 2
]
arm = player.send((loss, advice))
assert arm in range(3)

loss = 1 / (1 + arm)  # Arbitrary loss assigned to arm.
advice = [
    [0, 0, 1],        # Expert 1
    [0, 0, 1],        # Expert 2
]
arm = player.send((loss, advice))
assert arm == 2

Metadata

Release files for exp4 0.1.4

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

Source distribution (sdist)

Source distribution for exp4 0.1.4
File Size Uploaded
exp4-0.1.4.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for exp4 0.1.4
File Interpreter ABI Platform
exp4-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / exp4-0.1.4.tar.gz

Download URL exp4-0.1.4.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2c8e4f72d30cc6ef0324eb1c1d49963b20cb0523a1b17b60f49f1b23281ae480
BLAKE2b-256 checksum
How to use checksums
0a1fac89e395303e9248cf8b8f2650ef76a2e36ba939957df3069898f4793743
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.9.6 Linux/5.13.5-1-MANJARO

Release files / exp4-0.1.4-py3-none-any.whl

Download URL exp4-0.1.4-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef11848f628e6c2b7b612680bc3cfee86556a726a52d75bbc751047cf55783c1
BLAKE2b-256 checksum
How to use checksums
5f0b2906d603beb90d3739db0a09d872f502e514cc53324fc2547a823188ea7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.9.6 Linux/5.13.5-1-MANJARO

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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