How swagath18/a-b-testing-recommender-system works
Project Type and Purpose
• This is a full-stack, data-driven web application for simulating and visualizing an A/B test between two recommender engines.
• It combines a Streamlit frontend UI, Python modules for recommendation logic and evaluation, and MLflow for experiment tracking.
File Structure Analysis
• data/: Static CSV datasets (interactions.csv, item_metadata_tfidf.csv)
• src/: Core Python modules
• recommend_baseline.py – popularity-based recommender
• recommend_new.py – TF-IDF–based recommender
• ab_test.py – A/B assignment & CTR simulation
• evaluation.py – lift calculation and statistical tests
• streamlit_app.py: Entry point for the interactive UI
• main.py (mentioned in README): Offline batch evaluation script
• requirements.txt & MLflow config: Environment setup and experiment tracking
Main Components
a. Frontend (Streamlit UI)
• streamlit_app.py renders pages, collects user requests, displays recommendations and metrics.
b. Backend Logic
• A/B Test Controller (ab_test.py)
• Recommender Engines (baseline & TF-IDF modules)
• Evaluation Engine (evaluation.py)
c. Data Layer
• Datasets in data/
• In-memory Pandas DataFrames at runtime
d. Experiment Tracking
• MLflow server & local artifact store
e. Offline Batch Runner
• main.py triggers evaluation without UI
Component Interactions
• Streamlit UI → calls A/B Test Controller →
• fetches user group, invokes appropriate recommender → returns item list → UI shows recommendations
• UI records simulated clicks → passes results to evaluation module → calculates CTR & lift → logs all metrics to MLflow
• main.py orchestrates same calls in batch mode and prints results
Architectural Patterns and Principles
• Layered design:
• Presentation layer (Streamlit)
• Business logic layer (A/B, recommenders, evaluation)
• Data layer (CSV files, DataFrames)
• Infrastructure layer (MLflow tracking)
• Single-process monolith, clear separation of concerns by module
• Configurable components (e.g., switching in new recommenders)