|
|
||
|---|---|---|
| azure-app | ||
| docs | ||
| notebook | ||
| fetch-data.sh | ||
| LICENSE | ||
| README.fr.md | ||
| README.md | ||
| streamlit_app.py | ||
| streamlit_requirements.txt | ||
Source of truth : https://git.gregoiremureau.com/openclassroom-ai/oc-p10-content-recommendation
git clone https://git.gregoiremureau.com/openclassroom-ai/oc-p10-content-recommendation.git
git clone https://git.gregoiremureau.com/openclassroom-ai/oc-p10-content-recommendation.git
Dataset: see fetch-data.sh (excluded from git if large).
Content Recommendation System - My Content
📘 This project is also available in French 🇫🇷
Project developing an article recommendation system based on a serverless Azure Functions architecture with a Streamlit user interface.
Project Deliverables
- Working application: Streamlit + Azure Functions deployed
- Versioned source code: Complete GitHub repository
- Technical presentation: PDF deck (docs/presentation.pdf)
Overview
This project implements a content recommendation system using collaborative filtering and content-based algorithms. The serverless architecture enables automatic scaling and optimized cost.
Main Features
- Recommendation API: Azure Function returning the top 5 recommended articles for a user
- User interface: Streamlit application to test and demonstrate the system
- Implemented algorithms: Content-Based Filtering with precomputed embeddings
- Serverless architecture: Deployment on Azure Functions with Consumption plan
Analysis and Development
Jupyter Notebook
- Data exploration: Analysis of the Kaggle Globo.com dataset
- Algorithm implementation: Content-Based and Collaborative Filtering
- Approach comparison: Evaluation and technical choice
- PCA optimization: Dimensionality reduction 250D → 50D
Location: notebook/p10_notebook.ipynb
Architecture
Current MVP
[Streamlit Interface] → [Azure Functions API] → [Recommendation Algorithm]
↓
[Embeddings data + user history]
Components
- Frontend: Streamlit (test interface)
- Backend: Azure Functions (Python 3.12, Linux)
- Algorithm: Content-Based Filtering with cosine similarity
- Data: Article embeddings (50D via PCA vs 250D original embeddings) + click history
Project Structure Overview
Project_10/
├── azure-app/ # Azure Function
│ ├── function_app.py # Azure Function entry point
│ ├── requirements.txt # Python dependencies
│ ├── host.json # Azure Functions configuration
│ ├── local.settings.json # Local configuration (not versioned)
│ ├── data/
│ │ ├── embeddings_azure_50d.pkl # Article embeddings (PCA 50D)
│ │ └── clicks_sample.csv # User click history
│ └── utils/
│ ├── data_loader.py # Data loading and caching
│ └── content_based.py # Recommendation algorithm
├── notebook/
│ └── p10_notebook.ipynb # Data analysis + model development
├── docs/
│ ├── presentation.pdf # Presentation deck (15-25 slides)
│ └── illustrations/ # Architecture diagrams and screenshots
├── streamlit_app.py # User interface
├── streamlit_requirements.txt # Streamlit dependencies
└── README.md
Installation and Deployment
Prerequisites
- Python 3.12+
- Azure CLI
- Azure Functions Core Tools
- Azure account
Azure Functions Deployment
- Sign in to Azure
az login
- Infrastructure creation
# Resource group
az group create --name rg-content-recommender --location francecentral
# Storage account
az storage account create --name [your-unique-storage-name] \
--resource-group rg-content-recommender \
--location francecentral \
--sku Standard_LRS
# Linux Function App with Python 3.12
az functionapp create \
--resource-group rg-content-recommender \
--consumption-plan-location francecentral \
--runtime python \
--runtime-version 3.12 \
--functions-version 4 \
--name contentrecommender-linux \
--storage-account stcontentrecommend2025 \
--os-type Linux
- Code deployment
# From the azure-app folder
func azure functionapp publish contentrecommender-linux
Streamlit Interface
- Install dependencies
pip install -r streamlit_requirements.txt
- Launch the interface
streamlit run streamlit_app.py
Usage
Azure Functions API
Endpoint: https://contentrecommender-linux.azurewebsites.net/api/recommend
Parameters:
user_id(int): User identifier (0-706)
Example call:
curl "https://contentrecommender-linux.azurewebsites.net/api/recommend?user_id=0"
Response:
{
"user_id": 0,
"recommendations": [157519, 157944, 159495, 156690, 162857]
}
Streamlit Interface
- Configure the API URL (local or Azure)
- Select a user ID
- Get the recommendations
- Test the advanced features
Recommendation Algorithm
Content-Based Filtering
- Data loading: Precomputed embeddings and user history
- User profile computation: Average of the embeddings of the viewed articles
- Cosine similarity: Computed against all articles in the catalog
- Filtering: Exclusion of already-seen articles
- Selection: Top 5 most similar articles
Optimizations
- Dimensionality reduction: PCA 250D → 50D to optimize Azure performance
- In-memory cache: Embeddings and user data loaded only once
- Serverless architecture: Automatic scaling based on demand
Tests and Validation
Local tests
# Start Azure Functions locally
func start
# Test the algorithm
python test_local.py
Performance metrics
- Response time: ~200ms per recommendation
- Supported users: 707 in the current dataset
- Available articles: 364,047 with embeddings
Known Issues and Solutions
Azure Deployment
- Python on Windows: Not supported, must use Linux
- Authentication: Set
http_auth_level=func.AuthLevel.ANONYMOUS - "Service unavailable" errors: Temporary Azure issues, retry later
Current Limitations
- Cold start: First request is slow after a period of inactivity
- New users: No handling of the cold-start problem
- Data updates: Manual process
Target Architecture (Future)
Planned Improvements
- Cold start handling: Popular recommendations for new users
- Data pipeline: Automatic embeddings update
- Database: Persistent storage of user profiles
- Hybrid API: Combination of Content-Based + Collaborative Filtering
- Distributed cache: Precomputation of popular recommendations
Technologies Used
- Backend: Azure Functions, Python 3.12
- Frontend: Streamlit
- ML/Data: scikit-learn, pandas, numpy
- Infrastructure: Azure CLI, Azure Storage
- Deployment: Azure Functions Core Tools
Author
Project carried out as part of an OpenClassrooms training program - AI Engineer.
License
This project is for educational purposes only.