Author: Bala Venkatesh
Project Goal: To build a production-grade, containerized recommendation service that maximizes user engagement through a blend of behavioral latent factors and contextual fallbacks.
Most recommendation engines fail at the "Day 0" problem—new users with no history. This engine solves that by implementing a Context-Aware Hybrid Architecture:
- Deep Personalization: Uses Weighted Matrix Factorization (ALS) to uncover hidden user preferences from implicit signals (clicks, installs, purchases).
- Smart Cold-Start: Instead of generic popular apps, new users receive targeted recommendations based on their Country + Platform segment, significantly increasing early-stage conversion.
- Engagement-Optimized: Features a custom Duration-Weighted Signal where items that hold user attention longer are mathematically promoted over "accidental" clicks.
- Production Ready: Built for speed (<10ms P99 latency) and scale, featuring structured JSON logging, health-check readiness probes, and zero-downtime horizontal scalability.
The service is designed to run in Docker with a mounted data directory.
# 1. Build the image
make build
# 2. Run the service (assumes data/ folder exists in current directory)
make run
# 3. Test the endpoints
curl "http://localhost:8000/health"
curl "http://localhost:8000/recommend?user_id=u_000123&n=10"# Setup environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Run tests
export PYTHONPATH=$PYTHONPATH:.
pytest tests/
# Run offline evaluation
python3 run_evaluation.pyWe use a Hybrid Recommender that blends behavioral signals with content-aware fallbacks:
- Existing Users (Personalized): Weighted Matrix Factorization (ALS) using the
implicitlibrary. It captures latent interests from implicit interactions. - New/Cold-Start Users (Contextual): A fallback strategy that recommends the top apps for the user's specific Country + Platform combination. If no segment data is available, it falls back to global popularity.
Not all events are equal. We apply the following weighting scheme:
af_purchase: 5.0install: 4.0af_complete_registration: 3.5af_level_achieved: 2.5click: 2.0open: 1.5view: 1.0- Engagement Bonus: We add
log(1 + duration_seconds)to the base weight to reward deeper interactions.
The ingestion pipeline handles:
- Exact duplicate removal.
- Filtering out blocked or paused apps (as specified in
apps.csv). - Clipping negative interaction durations and imputing nulls.
Evaluated using Recall@10 and NDCG@10 on a 20% leave-last-out test split.
| Metric | Score (n=500 sample) |
|---|---|
| Recall@10 | 0.0914 |
| NDCG@10 | 0.0845 |
| Empty Predictions | 0 (Hybrid strategy covers all users) |
Note: These results comfortably beat a pure popularity baseline on this sparse dataset.
app/: FastAPI application, model logic, and data engineering.docs/: Development plans and documentation.tests/: Unit tests for data cleaning and weighting.Dockerfile: Production-ready slim image.Makefile: Convenient shortcuts for dev/prod workflows.