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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exp4-0.1.4.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

exp4-0.1.4-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file exp4-0.1.4.tar.gz.

File metadata

  • Download URL: exp4-0.1.4.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.13.5-1-MANJARO

File hashes

Hashes for exp4-0.1.4.tar.gz
Algorithm Hash digest
SHA256 2c8e4f72d30cc6ef0324eb1c1d49963b20cb0523a1b17b60f49f1b23281ae480
MD5 6bd5c18b88cb7ae0dcd01c216d5b8e35
BLAKE2b-256 0a1fac89e395303e9248cf8b8f2650ef76a2e36ba939957df3069898f4793743

See more details on using hashes here.

File details

Details for the file exp4-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: exp4-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.6 Linux/5.13.5-1-MANJARO

File hashes

Hashes for exp4-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ef11848f628e6c2b7b612680bc3cfee86556a726a52d75bbc751047cf55783c1
MD5 e48dd5756e571515f73bd1f707b0d106
BLAKE2b-256 5f0b2906d603beb90d3739db0a09d872f502e514cc53324fc2547a823188ea7b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page