How fidelity/mabwiser works
Project Type & Purpose
• MABWiser is a Python library intended for rapidly prototyping multi-armed bandit algorithms. It is used in contexts such as recommender systems and combinatorial optimization.
• The library implements a number of learning policies (e.g., UCB1, Thompson Sampling, Epsilon Greedy, etc.) as well as neighborhood policies (e.g., Clusters, LSH Nearest) with built-in parallelization support for both training and testing.
• Its scikit-learn style interface makes it seamless to integrate into other projects like Mab2Rec (for recommender systems) or Adaptive Large-Neighborhood Search (ALNS) for optimization problems.
Analyzing the File Structure
• Key Directories:
• The "mabwiser" directory holds the core library code including modules such as base_mab.py, greedy.py, linear.py, mab.py, simulator.py, ucb.py, and additional algorithm implementations.
• The "tests" directory contains unit tests that check various algorithm implementations and integration points.
• The "docs" and "docsrc" directories include Sphinx documentation with source texts, static assets, and build configuration files, which help define the external API and usage examples.
• The "examples" directory offers real-world usage examples (e.g., context-free, contextual, parallel, parametric bandit examples) that illustrate how to interact with the library and its simulation utilities.
• Other files like setup.py, requirements.txt, and CI/CD YAML workflows show that the project is packaged, continuously integrated, and expected to follow modern Python packaging standards.
Key Components
a. Core Components:
• Library Core (mabwiser module): This is the heart of the system. Show a central block labeled “MABWiser Core” that encapsulates various submodules:
• Base classes (e.g., Base MAB, utilities)
• Multiple Learning Policies (e.g., UCB1, Thompson Sampling, Epsilon Greedy, LinTS, etc.)
• Neighborhood Policies (e.g., Clusters, K-Nearest, LSH Nearest)
• Simulator/Training & Prediction Interfaces – the components that handle fitting on data and decision-making.
b. Supporting Components:
• Testing Suite: A block representing "Tests" that interacts with the MABWiser Core to ensure correctness of algorithms.
• CI/CD Pipeline: Denote a “CI/CD” block (with .github workflows) that automatically runs tests and integration processes, ensuring stable builds.
• External Integrations: Optionally include integrations with dependent systems like scikit-learn (for the interface) and external packages used for parallelization.
Relationships and Data Flow
• Internecine interactions within the core:
• How the main MAB class delegates to the specific learning or neighborhood policy modules.
• How the Simulator interacts with the core to run parallelized training and testing.
• A feedback loop where simulations or predictions might inform hyperparameter tuning or further algorithm selection.
Architectural Patterns and Design Principles
• The project follows a modular design where each learning and neighborhood policy is implemented as a separate module. Emphasize the plug-and-play nature of algorithm components (fostering extensibility and ease of adding new policies).
• It adopts a “scikit-learn style” API, so the design is influenced by standardized model–fit/predict patterns.
Final Details
• Avoid over-complicating by focusing only on key relationships. Emphasize the separation of concerns—the interface, core functionality (with policy modules), simulation utilities, and integration components.