Add Multi-Armed Bandit (MAB) algorithms and evaluation utilities #833
+3,081
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
This PR introduces a set of classical Multi-Armed Bandit (MAB) algorithms and supporting utilities to the CausalML codebase. The implementation includes:
Core MAB algorithms in
causalml/causalml/optimize/bandit.py
:Simulation utilities in
causalml/causalml/dataset/mab_simulation.py
:Evaluation metrics in
causalml/causalml/metrics/mab_evaluation.py
:Example notebooks:
mab_bandit_model_demo.ipynb
: A comprehensive demonstration of all MAB algorithms, including:mab_bandit_model_comparison.ipynb
: A focused comparison of different MAB algorithms with:Unit tests in
causalml/tests/test_bandit.py
This addition provides a foundation for experimentation and benchmarking of bandit algorithms within the CausalML ecosystem, supporting both research and practical applications.
Types of changes
What types of changes does your code introduce to CausalML?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
The implementation follows the existing CausalML codebase structure and style, with a focus on:
The MAB algorithms are implemented as classes that inherit from a common base class, making it easy to add new algorithms in the future. The evaluation utilities provide both numerical metrics and visualization tools, making it easy to compare different algorithms' performance.
The implementation has been tested with various scenarios, including:
All algorithms have been benchmarked against each other to ensure they perform as expected in different scenarios. The example notebooks provide clear demonstrations of how to use each algorithm type and how to interpret their performance.
Recent improvements include:
n_arms
parameterBatchBandit
wrapper correctlyLinUCB
updates