Spaces:
Sleeping
Sleeping
| title: AdRL Studio | |
| colorFrom: purple | |
| colorTo: blue | |
| sdk: docker | |
| app_port: 7860 | |
| pinned: false | |
| <div align="center"> | |
| <h1>π― AdRL Studio</h1> | |
| <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&size=22&duration=3000&pause=1000&color=7C3AED¢er=true&vCenter=true&width=700&lines=Contextual+Bandit+Ad+Recommendation+Engine;Benchmark+%CE%B5-Greedy%2C+UCB1%2C+Thompson%2C+LinUCB;Real-Time+Ad+Serving+%2B+Regret+Analysis" alt="Typing SVG"/> | |
| <br/> | |
| [](https://www.python.org/) | |
| [](https://flask.palletsprojects.com/) | |
| [](https://www.docker.com/) | |
| [](https://huggingface.co/mnoorchenar/spaces) | |
| [](#) | |
| <br/> | |
| **π― 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. | |
| <br/> | |
| --- | |
| </div> | |
| ## 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 | |
| <table> | |
| <tr> | |
| <td>π― <b>Live Ad Serving</b></td> | |
| <td>Enter user context (age, device, time, category, region) and get real-time ad recommendations from all 4 algorithms simultaneously</td> | |
| </tr> | |
| <tr> | |
| <td>βΆ <b>Online Learning Simulation</b></td> | |
| <td>Run 1Kβ10K impression simulations with SSE-streamed progress, rolling CTR charts, and per-algorithm summaries</td> | |
| </tr> | |
| <tr> | |
| <td>π <b>Regret Analysis</b></td> | |
| <td>Visualize cumulative regret curves β the canonical RL evaluation metric β comparing all four policies</td> | |
| </tr> | |
| <tr> | |
| <td>β <b>A/B Test Simulator</b></td> | |
| <td>Run 50/50 traffic splits with two-proportion z-test, p-value, confidence intervals, and statistical significance verdict</td> | |
| </tr> | |
| <tr> | |
| <td>π <b>Secure by Design</b></td> | |
| <td>Role-based access, audit logs, encrypted data pipelines</td> | |
| </tr> | |
| <tr> | |
| <td>π³ <b>Containerized Deployment</b></td> | |
| <td>Docker-first architecture, cloud-ready and scalable</td> | |
| </tr> | |
| </table> | |
| --- | |
| ## ποΈ 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 | |
| <div align="center"> | |
| <table> | |
| <tr> | |
| <td align="center" width="100%"> | |
| <img src="https://avatars.githubusercontent.com/mnoorchenar" width="120" style="border-radius:50%; border: 3px solid #4f46e5;" alt="Mohammad Noorchenarboo"/> | |
| <h3>Mohammad Noorchenarboo</h3> | |
| <code>Data Scientist</code> | <code>AI Researcher</code> | <code>Biostatistician</code> | |
| π Ontario, Canada π§ [mohammadnoorchenarboo@gmail.com](mailto:mohammadnoorchenarboo@gmail.com) | |
| ββββββββββββββββββββββββββββββββββββββ | |
| [](https://www.linkedin.com/in/mnoorchenar) | |
| [](https://mnoorchenar.github.io/) | |
| [](https://huggingface.co/mnoorchenar/spaces) | |
| [](https://scholar.google.ca/citations?user=nn_Toq0AAAAJ&hl=en) | |
| [](https://github.com/mnoorchenar) | |
| </td> | |
| </tr> | |
| </table> | |
| </div> | |
| --- | |
| ## π€ 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 | |
| <span style="color:red">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.</span> | |
| --- | |
| ## π License | |
| Distributed under the **MIT License**. See [`LICENSE`](LICENSE) for more information. | |
| --- | |
| <div align="center"> | |
| <img src="https://capsule-render.vercel.app/api?type=waving&color=0:3b82f6,100:4f46e5&height=120§ion=footer&text=Made%20with%20%E2%9D%A4%EF%B8%8F%20by%20Mohammad%20Noorchenarboo&fontColor=ffffff&fontSize=18&fontAlignY=80" width="100%"/> | |
| [](https://github.com/mnoorchenar/AdRL-Studio) | |
| [](https://github.com/mnoorchenar/AdRL-Studio/fork) | |
| <sub>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.</sub> | |
| </div> | |