How saifh-github/conservative-bayesian-public works
Project Type & Purpose
• This is an experimental research codebase in Python, organized as a small “experiment pipeline” rather than a full‐stack web app.
• Its purpose is to run two main experiments (non-IID and tightness), simulate Bayesian agents interacting with environments, and produce the figures for the Bengio et al. (2024) paper.
File Structure
• Top-level scripts:
• run_non_iid_experiment.py / .sh
• run_tightness_experiment.py / .sh
• plotting drivers: make_non_iid_plots.py, make_tightness_plots.py, etc.
• Core modules:
• agents/ – defines Agent classes and the guardrails logic.
• envs/ – defines the environment interface and a specific “exploding_bandit” environment.
• utils/ – general helpers and plotting routines.
• Config & tooling:
• environment.yaml – conda dependencies (numpy, pytest, matplotlib, etc.)
• test_guardrails.py – unit tests for guardrail logic.
Extract Key Architectural Insights from README
• Two experiment entry points correspond directly to Figures 1 and 2.
• There is no external service; everything runs locally under the conda environment.
• Outputs are static plot files.
Main Components & Their Interactions
a. Entry-point Scripts
• run_non_iid_experiment.py
• run_tightness_experiment.py
→ These orchestrate experiments: instantiate environments and agents, loop simulation steps, collect results.
b. Agent Module (agents/)
• agents.py: base Agent classes (e.g., Bayesian Oracle)
• guardrails.py: logic to constrain or modify agent actions
c. Environment Module (envs/)
• exploding_bandit.py: environment dynamics, reward generation
• Experiment wrappers handle batching / non-IID/tightness parameters
d. Utilities (utils/)
• utils.py: data-collection, metrics
• plotting.py: figure creation, styling
e. Plot Scripts
• make_*.py: load experiment outputs, call utils.plotting to recreate manuscript figures
f. Test Suite
• test_guardrails.py: verify guardrail behavior in isolation
Architectural Patterns & Design Principles
• Modular separation by concern:
• Orchestration (scripts) vs. Domain logic (agents/envs) vs. Presentation (plotting).
• Clear dependency direction: scripts → core modules → utils
• Single Responsibility: each module does one thing (simulate, constrain, plot).