--- title: AdRL Studio colorFrom: purple colorTo: blue sdk: docker app_port: 7860 pinned: false ---

🎯 AdRL Studio

Typing SVG
[![Python](https://img.shields.io/badge/Python-3.10+-3b82f6?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/) [![Flask](https://img.shields.io/badge/Flask-2.x-4f46e5?style=for-the-badge&logo=flask&logoColor=white)](https://flask.palletsprojects.com/) [![Docker](https://img.shields.io/badge/Docker-Ready-3b82f6?style=for-the-badge&logo=docker&logoColor=white)](https://www.docker.com/) [![HuggingFace](https://img.shields.io/badge/HuggingFace-Spaces-ffcc00?style=for-the-badge&logo=huggingface&logoColor=black)](https://huggingface.co/mnoorchenar/spaces) [![Status](https://img.shields.io/badge/Status-Active-22c55e?style=for-the-badge)](#)
**🎯 AdRL Studio** β€” A contextual multi-armed bandit platform that simulates a real-world ad recommendation and serving system using reinforcement learning. Benchmarks four bandit algorithms side by side, visualizes online learning and regret curves, runs A/B test simulations with statistical significance testing, and serves real-time ad recommendations from user context input.
---
## Table of Contents - [Features](#-features) - [Architecture](#️-architecture) - [Getting Started](#-getting-started) - [Docker Deployment](#-docker-deployment) - [Dashboard Modules](#-dashboard-modules) - [ML Models](#-ml-models) - [Project Structure](#-project-structure) - [Author](#-author) - [Contributing](#-contributing) - [Disclaimer](#disclaimer) - [License](#-license) --- ## ✨ Features
🎯 Live Ad Serving Enter user context (age, device, time, category, region) and get real-time ad recommendations from all 4 algorithms simultaneously
β–Ά Online Learning Simulation Run 1K–10K impression simulations with SSE-streamed progress, rolling CTR charts, and per-algorithm summaries
πŸ“‰ Regret Analysis Visualize cumulative regret curves β€” the canonical RL evaluation metric β€” comparing all four policies
βš– A/B Test Simulator Run 50/50 traffic splits with two-proportion z-test, p-value, confidence intervals, and statistical significance verdict
πŸ”’ Secure by Design Role-based access, audit logs, encrypted data pipelines
🐳 Containerized Deployment Docker-first architecture, cloud-ready and scalable
--- ## πŸ—οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ AdRL Studio β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Simulated│───▢│ Bandit │───▢│ Flask API β”‚ β”‚ β”‚ β”‚ Ad Environβ”‚ β”‚ Algorithmsβ”‚ β”‚ Backend β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Plotly Charts β”‚ β”‚ β”‚ β”‚ Dashboard β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸš€ Getting Started ### Prerequisites - Python 3.10+ - Docker & Docker Compose - Git ### Local Installation ```bash # 1. Clone the repository git clone https://github.com/mnoorchenar/AdRL-Studio.git cd AdRL-Studio # 2. Create a virtual environment python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate # 3. Install dependencies pip install -r requirements.txt # 4. Configure environment variables cp .env.example .env # Edit .env with your settings # 5. Run the application python app.py ``` Open your browser at `http://localhost:7860` πŸŽ‰ --- ## 🐳 Docker Deployment ```bash # Build and run with Docker Compose docker compose up --build # Or pull and run the pre-built image docker pull mnoorchenar/AdRL-Studio docker run -p 7860:7860 mnoorchenar/AdRL-Studio ``` --- ## πŸ“Š Dashboard Modules | Module | Description | Status | |--------|-------------|--------| | 🎯 Live Ad Serving | Real-time 4-algorithm recommendation from user context | βœ… Live | | β–Ά Online Learning | Simulation with SSE streaming and rolling CTR charts | βœ… Live | | πŸ“‰ Regret Analysis | Cumulative regret curves for all four algorithms | βœ… Live | | βš– A/B Test Simulator | Statistical significance testing with z-test & CI | βœ… Live | | 🌑 Reward Landscape | 5Γ—5 CTR heatmap: user content category Γ— ad category | βœ… Live | | πŸ”¬ Policy Inspector | Per-ad learned weights and posterior distributions | πŸ—“οΈ Planned | --- ## 🧠 ML Models ```python # Core Models Used in AdRL Studio models = { "epsilon_greedy": "Ξ΅-Greedy Neural Bandit β€” shared PyTorch MLP (39β†’32β†’16β†’1) with decaying Ξ΅", "ucb1": "UCB1 β€” Upper Confidence Bound non-contextual baseline", "thompson": "Thompson Sampling β€” Bayesian Beta(Ξ±,Ξ²) per arm", "linucb": "LinUCB Disjoint β€” ridge regression contextual bandit (production-grade)", "environment": "Simulated 20-ad inventory, 19-dim one-hot context, Bernoulli reward sampling" } ``` --- ## πŸ“ Project Structure ``` AdRL-Studio/ β”‚ β”œβ”€β”€ πŸ“„ app.py # Complete Flask application β€” all logic, templates, and API β”œβ”€β”€ πŸ“„ Dockerfile # Container definition (python:3.10-slim, port 7860) β”œβ”€β”€ πŸ“„ requirements.txt # Python dependencies └── πŸ“„ README.md # This file ``` > All application logic, HTML templates, CSS, and JavaScript live inside `app.py` > using Flask's `render_template_string`. There are no external static files. --- ## πŸ‘¨β€πŸ’» Author
Mohammad Noorchenarboo

Mohammad Noorchenarboo

Data Scientist  |  AI Researcher  |  Biostatistician πŸ“  Ontario, Canada    πŸ“§  [mohammadnoorchenarboo@gmail.com](mailto:mohammadnoorchenarboo@gmail.com) ────────────────────────────────────── [![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/mnoorchenar)  [![Personal Site](https://img.shields.io/badge/Website-mnoorchenar.github.io-4f46e5?style=for-the-badge&logo=githubpages&logoColor=white)](https://mnoorchenar.github.io/)  [![HuggingFace](https://img.shields.io/badge/HuggingFace-ffcc00?style=for-the-badge&logo=huggingface&logoColor=black)](https://huggingface.co/mnoorchenar/spaces)  [![Google Scholar](https://img.shields.io/badge/Scholar-4285F4?style=for-the-badge&logo=googlescholar&logoColor=white)](https://scholar.google.ca/citations?user=nn_Toq0AAAAJ&hl=en)  [![GitHub](https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/mnoorchenar)
--- ## 🀝 Contributing Contributions are welcome! Please follow these steps: 1. **Fork** the repository 2. **Create** a feature branch: `git checkout -b feature/amazing-feature` 3. **Commit** your changes: `git commit -m 'Add amazing feature'` 4. **Push** to the branch: `git push origin feature/amazing-feature` 5. **Open** a Pull Request --- ## Disclaimer This project is developed strictly for educational and research purposes and does not constitute professional advice of any kind. All datasets used are either synthetically generated or publicly available β€” no real user data is stored. This software is provided "as is" without warranty of any kind; use at your own risk. --- ## πŸ“œ License Distributed under the **MIT License**. See [`LICENSE`](LICENSE) for more information. ---
[![GitHub Stars](https://img.shields.io/github/stars/mnoorchenar/AdRL-Studio?style=social)](https://github.com/mnoorchenar/AdRL-Studio) [![GitHub Forks](https://img.shields.io/github/forks/mnoorchenar/AdRL-Studio?style=social)](https://github.com/mnoorchenar/AdRL-Studio/fork) The name "AdRL Studio" is used purely for academic and research purposes. Any similarity to existing company names, products, or trademarks is entirely coincidental and unintentional. This project has no affiliation with any commercial entity.