> For the complete documentation index, see [llms.txt](https://www.mlcompendium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.mlcompendium.com/decision-intelligence/contextual-bandits.md).

# Contextual Bandits

A plain bandit picks arms from their history alone; a contextual bandit chooses actions using side information too. The page opens with an overview deck and a personalization talk, then a Tools section with the Python packages that implement the idea.

The same notes are in [A/B Testing](/decision-intelligence/a-b-testing.md), [Multi Armed Bandits](/decision-intelligence/multi-armed-bandits.md), and [Reinforcement Learning](/decision-intelligence/reinforcement-learning.md).

The overview is [Contextual bandits](https://drive.google.com/file/d/1EiLlajcSanTE19BOFKOTOlzHJxYSxz7w/view), the Contextual Bandits.pdf deck. It came via [personalization in practice](https://booking.ai/personalization-in-practice-2bb4bc680eb3), the personalization talk it belongs to.

## Tools

After the overview, the question is what to run. [contextualbandits.com](http://web.archive.org/web/20250809185312/https://contextualbandits.com/) is the hosted option — adapt your creative according to context and outcomes automatically without A/B-sitting your campaigns. For code, [Striatum](https://github.com/ntucllab/striatum) is ntucllab/striatum on GitHub, contextual bandits in python.

The fuller package is [Contextual bandits](https://github.com/david-cortes/contextualbandits), in python by David Cortes, and its README says what it is for:

"This Python package contains implementations of methods from different papers dealing with contextual bandit problems, as well as adaptations from typical multi-armed bandits strategies. It aims to provide an easy way to prototype and compare ideas, to reproduce research papers that don't provide easily-available implementations of their proposed algorithms, and to serve as a guide in learning about contextual bandits. For details about the implementations, or if you would like to cite this in your research, see ["Adapting multi-armed bandits policies to contextual bandits scenarios"](https://arxiv.org/abs/1811.04383)."

The figure below is from that package.

<figure><img src="https://83674056-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mgd48oS5_duTKOVE_Et%2Fuploads%2FMvkGLccuoS7ZS01DnuhK%2Fimage.png?alt=media&amp;token=38fcda85-479c-4871-a041-a1b8243198f4" alt=""><figcaption><p>Contextual bandits package.</p></figcaption></figure>

## Deprecated links

{% hint style="warning" %}
These links and images no longer work. The original wording is kept here. A same-resource copy, when one was checked, is used above.
{% endhint %}

* contextualbandits.com — adapt your creative according to context and outcomes automatically without A/B-sitting your campaigns. This address no longer opens: <https://www.contextualbandits.com/>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.mlcompendium.com/decision-intelligence/contextual-bandits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
