End-to-end recommendation system built on implicit user behavior, featuring offline evaluation, multiple collaborative filtering models, a production-style FastAPI service, and a Streamlit demo UI.
This project mirrors how real-world recommender systems are trained, evaluated, and served in modern e-commerce platforms.
In real-world e-commerce, users rarely provide explicit ratings. Instead, recommendation systems must learn from implicit signals such as:
- product views
- clicks
- add-to-cart events
- purchases
The challenge is to build a system that balances:
- Ranking accuracy → relevant recommendations
- Catalog coverage → discovery beyond popular items
- Interpretability → business trust & explainability
This project explores that trade-off using multiple collaborative filtering approaches and a hybrid strategy inspired by production systems.
- Implicit interaction data (no ratings)
- Time-aware split with 1 held-out future item per user
- Evaluation on Validation and Test sets
- Metrics:
- Recall@K
- NDCG@K
- Coverage@K (fraction of catalog surfaced)
This setup closely reflects the real business question:
“Can we rank the next item a user is likely to interact with?”
Ranks items by global interaction frequency.
Purpose
- Sanity check
- Cold-start fallback
Limitation
- Severe popularity bias
- Near-zero personalization and coverage
Learns item similarity from user co-interaction patterns .
Strengths
- Strong personalization over popularity
- Very high catalog coverage (~48%)
- Highly interpretable (“users who interacted with X also interacted with Y”)
Best suited for
- Similar-item carousels
- Discovery use cases
- Repeat users
Learns latent user and item embeddings from implicit feedback using Alternating Least Squares .
Strengths
- Best ranking accuracy (Recall@K, NDCG@K)
- Captures deeper personalization patterns
Trade-off
- Lower catalog coverage
- Less interpretable than item-item models
A weighted hybrid combining:
- ALS → ranking accuracy & personalization
- Item-Item → coverage, diversity, explainability
This mirrors how recommender systems are deployed in production to balance exploit vs explore .
Time-aware split, 1 held-out item per user
| Model | Split | Recall@10 | NDCG@10 | Coverage@10 | Recall@20 | NDCG@20 | Coverage@20 |
|---|---|---|---|---|---|---|---|
| Popularity | Test | 0.0059 | 0.0030 | 0.00017 | 0.0109 | 0.0043 | 0.00035 |
| Item-Item CF | Test | 0.0624 | 0.0319 | 0.4836 | 0.0947 | 0.0401 | 0.4913 |
| Implicit ALS | Test | 0.1182 | 0.0652 | 0.1056 | 0.1667 | 0.0775 | 0.1457 |
| Hybrid | Test | 0.1232 | 0.0677 | 0.1327 | 0.1748 | 0.0807 | 0.2064 |
The Hybrid model improves ranking quality over ALS while significantly increasing catalog coverage , achieving a more production-ready balance.
- Popularity is a necessary baseline but unsuitable alone
- Item-Item CF excels at discovery and explainability
- ALS delivers the strongest personalization
- Hybrid recommender offers the best real-world trade-off:
- High Recall / NDCG
- 2× coverage improvement over ALS
- Supports exploration without sacrificing relevance
| Use Case | Model |
|---|---|
| Homepage personalization | Hybrid |
| Similar-items carousel | Item-Item |
| Cold-start users | Popularity |
| Offline monitoring | Recall, NDCG, Coverage |
End-to-end reproducible pipeline:
python -m src.data.make_datasetpython -m src.features.build_featurespython -m src.models.popularitypython -m src.models.item_itempython -m src.models.mf_implicitpython -m src.models.hybridpython -m src.models.evaluate
Or run everything via:
python scripts/train_all.py
A production-style FastAPI service exposes recommendations via REST.
python -m uvicorn src.api.app:app --reload
Swagger UI:
http://127.0.0.1:8000/docs
| user_id | Description |
|---|---|
| 1085562 | High activity user |
| 1371942 | Medium activity |
| 1179363 | Low activity / near cold-start |
GET /recommend?user_id=1085562&model=hybrid&k=10GET /recommend?user_id=1085562&model=als&k=10GET /recommend?user_id=1085562&model=itemitem&k=10
A lightweight Streamlit app acts as a client for the FastAPI service.
streamlit run streamlit_app.py
Features:
- Model selection (popularity / item-item / ALS / hybrid)
- Real-time API calls
- Ranked results table
- JSON download for inspection
This repository includes:
Dockerfile.apiDockerfile.streamlitdocker-compose.yml
If Docker is installed:
docker compose up --build
Otherwise, both services can be run locally as shown above.
- Recommender system fundamentals (implicit feedback)
- Offline evaluation with business-relevant metrics
- Production-style model serving with FastAPI
- Client-service separation using Streamlit
- Hybrid modeling and cold-start handling
- End-to-end ML system thinking








