Conversation
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
|
@algorithms-keeper review |
|
@algorithms-keeper review |
|
@MaximSmolskiy, Hi, hope you are well. Can you please review this PR? It seems you are the most recent active maintainer. |
There was a problem hiding this comment.
🟡 Changes recommended
Return-type and doctest issues remain, along with requested cleanup and test/documentation updates.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a NumPy-based multi-armed bandit implementation with several strategies and a simulation visualization.
Changes:
- Adds bandit environment and selection strategies.
- Adds doctests and cumulative-reward plotting.
- Updates the generated directory index.
File summaries
| File | Summary |
|---|---|
machine_learning/mab.py |
Implements bandit models, strategies, and simulation. |
DIRECTORY.md |
Adds generated index entries; should be removed from the PR. |
Review details
Suppressed comments (6)
machine_learning/mab.py:109
- This constructor has no doctest, although the repository guideline requires every function to have at least one passing doctest. Add a small initialization example here so this new public API is covered directly.
def __init__(self, epsilon: float, num_arms: int) -> None:
"""
Initialize the Epsilon-Greedy strategy.
Args:
epsilon: The probability of exploring new arms.
num_arms: The number of arms.
"""
machine_learning/mab.py:169
- This constructor has no doctest, although the repository guideline requires every function to have at least one passing doctest. Add a small initialization example here so this new public API is covered directly.
def __init__(self, num_arms: int) -> None:
"""
Initialize the UCB strategy.
Args:
num_arms: The number of arms.
"""
machine_learning/mab.py:228
- This constructor has no doctest, although the repository guideline requires every function to have at least one passing doctest. Add a small initialization example here so this new public API is covered directly.
def __init__(self, num_arms: int) -> None:
"""
Initialize the Thompson Sampling strategy.
Args:
num_arms: The number of arms.
"""
machine_learning/mab.py:287
- This constructor has no doctest, although the repository guideline requires every function to have at least one passing doctest. Add a small initialization example here so this new public API is covered directly.
def __init__(self, num_arms: int) -> None:
"""
Initialize the Random strategy.
Args:
num_arms: The number of arms.
"""
machine_learning/mab.py:334
- This constructor has no doctest, although the repository guideline requires every function to have at least one passing doctest. Add a small initialization example here so this new public API is covered directly.
def __init__(self, num_arms: int) -> None:
"""
Initialize the Greedy strategy.
Args:
num_arms: The number of arms.
"""
machine_learning/mab.py:107
- The parameter description says epsilon explores “new arms,” but the implementation samples any arm, including one already tried. Document this as choosing a random arm so callers do not infer an unimplemented untried-arm guarantee.
epsilon: The probability of exploring new arms.
- Files reviewed: 2/2 changed files
- Comments generated: 7
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Cast rng.integers() results to Python int in EpsilonGreedy and RandomStrategy select_arm, fixing doctest flakiness from np.int64 - Fix grammar in module docstring and RandomStrategy docstring - Add missing doctest for Bandit.__init__ - Split test_mab_strategies into a real deterministic assertion-based test and a separate demo_mab_strategies for the stochastic plot - Revert DIRECTORY.md to upstream (auto-generated, out of scope here)
|
@MaximSmolskiy, ready for review. |
Describe your change:
Checklist:
What is added?
Multi-armed bandits (MAB) represent a class of sequential decision-making problems, where an agent chooses from multiple actions (or "arms") with uncertain rewards, aiming to maximize cumulative reward through balancing exploration (gathering information about each arm) and exploitation (leveraging known rewarding arms). It's one of the foundational algorithms in reinforcement learning and optimization contexts, as it models fundamental exploration-exploitation trade-offs that underpin decision-making processes. MAB algorithms, such as the epsilon-greedy, Upper Confidence Bound (UCB), and Thompson Sampling, find widespread applications across recommendation systems, adaptive clinical trials, online advertising, and resource allocation, effectively optimizing real-world decisions under uncertainty with minimal data collection.