Système complet d'analyse comportementale et de prédiction de conversion combinant:
- Modèle d'ensemble ML (LR, RF, XGBoost, LSTM)
- Recherche vectorielle avec Qdrant
- Suivi comportemental en temps réel (souris, scroll, clics)
- Marketplace e-commerce avec heatmap analytics
- Entraînement de modèles ML
- API FastAPI pour prédictions en temps réel
- Fichiers:
final.ipynb,app.py,test.py,ensemble_model.py
- Recherche de campagnes similaires
- Indexation avec embeddings
- Fichiers:
qdrant_indexer.py,embeddings.py,retrieval_test.py,train_pipeline.py
- Tracking de souris en temps réel
- Score comportemental
- Fichiers:
backend/main.py,frontend/behavior-tracker.js
- Application e-commerce React/TypeScript
- Mouse tracking & heatmap visualization
- Rapports UX automatisés en PDF
- Fichiers:
src/,heatmap-api.mjs,heatmap_plot.py
# Créer un environnement virtuel
python -m venv venv
.\venv\Scripts\Activate.ps1
# Installer les packages
pip install -r requirement.txt# Créer un environnement virtuel
python3 -m venv venv
source venv/bin/activate
# Installer les packages
pip install -r requirement.txtOption A: Via Jupyter Notebook (Recommandé)
jupyter notebook final.ipynbPuis exécutez toutes les cellules (Cell → Run All)
Option B: Via Script Python
python train_pipeline.py✅ Résultat attendu: Fichiers .pkl générés (modèles et preprocessors)
uvicorn app:app --reload🌐 Serveur accessible à: http://127.0.0.1:8000
python test.pyTest manuel avec curl:
curl -X POST "http://127.0.0.1:8000/predict" ^
-H "Content-Type: application/json" ^
-d "{\"age\": 25, \"click_count\": 10, \"last_time_spent\": 120, \"gender\": \"Male\", \"ad_source\": \"Facebook\", \"category_interest\": \"Tech\", \"previous_purchase_category\": \"Books\", \"visitor_type\": \"New\"}"Réponse attendue:
{
"prediction": 1,
"probability": 0.75
}docker run -p 6333:6333 qdrant/qdrantpython clean_campaign_data.pypython train_pipeline.py✅ Résultat: Base vectorielle créée dans Qdrant + embeddings.npy
python retrieval_test.py🎯 Fonction: Trouve des campagnes similaires qui ont converti
cd Desktop/404_not_found/backend
python main.py🌐 API disponible à: http://localhost:8000
cd ../frontend
# Ouvrir index.html dans un navigateur
start index.html # Windows
open index.html # macOS
xdg-open index.html # Linuxcd ../backend
python view_scores.pypython test_endpoint.pyApplication marketplace complète avec tracking mouse et génération de heatmaps.
# 1. Naviguer vers le dossier marketplace
cd marketplace-hub
# 2. Installer les dépendances Node
npm install
# 3. Installer les dépendances Python (pour heatmap/analytics)
pip install matplotlib pillow
# 4. Démarrer le serveur de développement
npm run dev🌐 Marketplace disponible à: http://localhost:5173
# Terminal 1: Démarrer le serveur API heatmap
node heatmap-api.mjs
# Terminal 2: Le tracking est maintenant actif!
# Utilisez l'application normalement
# Les données sont sauvegardées dans heatmap-data.json toutes les 5 secondes
# Générer les visualisations à tout moment
python heatmap_plot.py --api
# Créer des rapports d'analyse UX
python generate_ux_report_local.py --json heatmap-data.json --image heatmap.png --output UX_REPORT.pdf| Commande | Description |
|---|---|
npm run dev |
Serveur de développement Vite (port 5173) |
npm run build |
Build pour production |
npm run preview |
Preview du build production |
npm run lint |
Exécuter ESLint |
npm run test |
Exécuter les tests Vitest |
node heatmap-api.mjs |
Serveur API tracking (port 3001) |
python heatmap_plot.py --api |
Générer heatmap depuis l'API |
Visualisation interactive des métriques:
streamlit run dashboard.py🌐 Dashboard disponible à: http://localhost:8501
| Fichier | Description |
|---|---|
final.ipynb |
[PARTIE 1] Entraînement des modèles ML |
app.py |
[PARTIE 1] Serveur FastAPI pour prédictions |
test.py |
[PARTIE 1] Tests API de prédiction |
ensemble_model.py |
[PARTIE 1] Classe d'ensemble |
train_pipeline.py |
[PARTIE 2] Pipeline d'entraînement Qdrant |
qdrant_indexer.py |
[PARTIE 2] Indexation vectorielle |
embeddings.py |
[PARTIE 2] Génération d'embeddings |
retrieval_test.py |
[PARTIE 2] Tests de recherche |
config.py |
Configuration globale |
dashboard.py |
Dashboard Streamlit |
dataset.csv |
Données d'entraînement |
| Fichier | Description |
|---|---|
main.py |
[PARTIE 3] Serveur FastAPI comportemental |
behavior_scoring.py |
[PARTIE 3] Calcul du score |
feature_engineering.py |
[PARTIE 3] Extraction de features |
sequence_model.py |
[PARTIE 3] Modèle séquentiel |
view_scores.py |
[PARTIE 3] Affichage des scores |
test_endpoint.py |
[PARTIE 3] Tests API |
| Fichier | Description |
|---|---|
index.html |
[PARTIE 3] Page de démonstration |
behavior-tracker.js |
[PARTIE 3] Tracking JavaScript |
marketplace-hub/
├── src/
│ ├── components/ # Composants React
│ │ ├── home/ # Sections homepage
│ │ ├── layout/ # Layout (Header, Footer)
│ │ ├── products/ # Affichage produits
│ │ └── ui/ # Composants shadcn-ui
│ ├── context/ # React Context (Auth, Cart)
│ ├── data/ # Données produits
│ ├── hooks/ # Custom React hooks
│ ├── pages/ # Composants de page
│ │ └── admin/ # Pages admin dashboard
│ └── lib/ # Fonctions utilitaires
├── public/
│ └── tracking.js # Script mouse tracking (auto-load)
├── heatmap-api.mjs # API Express pour données tracking
├── heatmap_plot.py # Générateur de visualisation heatmap
├── generate_ux_report_local.py # Générateur de rapport UX local
├── heatmap-data.json # Stockage des données tracking
└── README.md # Documentation marketplace
- Entraîner les modèles:
jupyter notebook final.ipynb - Lancer l'API prédiction:
uvicorn app:app --reload - Tester:
python test.py - Dashboard:
streamlit run dashboard.py
- Démarrer Qdrant:
docker run -p 6333:6333 qdrant/qdrant - Indexer:
python train_pipeline.py - Rechercher:
python retrieval_test.py
- Backend:
cd Desktop/404_not_found/backend && python main.py - Frontend: Ouvrir
Desktop/404_not_found/frontend/index.html - Visualiser:
python view_scores.py
- Installation:
cd marketplace-hub && npm install - Démarrer l'app:
npm run dev - Activer tracking:
node heatmap-api.mjs(autre terminal) - Utiliser l'app: Naviguer sur
http://localhost:5173 - Générer heatmap:
python heatmap_plot.py --api - Rapport UX:
python generate_ux_report_local.py --json heatmap-data.json --image heatmap.png --output UX_REPORT.pdf - Effacer données:
window.clearAll()dans la console navigateur
pip install --upgrade -r requirement.txt# Pour l'API principale
uvicorn app:app --reload --port 8001
# Pour le backend comportemental
python main.py # Modifier le port dans main.py si nécessaire# Vérifier que Docker est démarré
docker ps
# Redémarrer Qdrant
docker run -p 6333:6333 qdrant/qdrant# Ré-entraîner les modèles
jupyter notebook final.ipynb
# Puis Run All Cells# 1. Vérifier que tracking.js est chargé (DevTools → Network)
# 2. Vérifier que l'API tourne: node heatmap-api.mjs
# 3. Vérifier la console navigateur pour les erreurs
# 4. Confirmer l'URL API dans tracking.js# Vérifier que le fichier de données existe
python -c "import json; print(len(json.load(open('heatmap-data.json'))))"
# Vérifier matplotlib installé
pip install matplotlib# Installer les dépendances manquantes
pip install pillow
# Vérifier que heatmap.png existe
ls heatmap.png # ou dir heatmap.png sur Windows# Changer le port Vite (vite.config.ts)
server: { port: 5174 }
# Changer le port API (heatmap-api.mjs)
const PORT = 3002;- Accuracy: ~85-90%
- ROC-AUC: ~0.88-0.92
- Output: Probabilité de conversion (0.0 - 1.0)
- Similarité: >99% pour campagnes proches
- Filtrage: Seulement campagnes converties
- Top-K: 5-10 campagnes similaires
- Score: 0.0 (faible intent) à 1.0 (fort intent)
- Temps réel: Latence < 100ms
- Features: Vitesse souris, scroll, hovers CTA
- Mouse Tracking: Position pixel-perfect avec timestamp
- Heatmaps: Haute résolution (150 DPI), couleurs bleu → rouge
- Rapports UX: Analyse statistique, recommandations, PDF
- Stockage: Append-only, sync automatique localStorage + API
- ML: scikit-learn, XGBoost, TensorFlow
- API: FastAPI, Uvicorn, Express.js
- Vectorielle: Qdrant, sentence-transformers
- Viz: Streamlit, Plotly, Matplotlib, Seaborn
- React 18 - UI library
- TypeScript - Type-safe JavaScript
- Vite - Build tool & dev server rapide
- React Router - Routing client-side
- shadcn-ui - Component library
- Tailwind CSS - Utility-first CSS
- Lucide Icons - Icon library
- JavaScript (Vanilla) - Tracking comportemental
- Python 3 - Data processing
- matplotlib - Heatmap visualization
- Pillow (PIL) - Génération PDF
Consultez les guides dans Desktop/404_not_found/:
QUICK_START.md- Guide de démarrage rapideHOW_TO_VIEW_SCORES.md- Visualisation des scoresTROUBLESHOOTING_500_ERROR.md- Résolution d'erreursWHAT_THIS_PROJECT_DOES.md- Explication détaillée
# 1. Installation
pip install -r requirement.txt
# 2. Entraînement rapide (optionnel si .pkl existent)
# jupyter notebook final.ipynb
# 3. Lancer l'API
uvicorn app:app --reload
# 4. Tester (dans un autre terminal)
python test.py
# 5. Dashboard (optionnel)
streamlit run dashboard.pyVoilà! Le système est opérationnel. 🎉
# Démarrer l'application
cd marketplace-hub
npm run dev
# Pages disponibles:
# - Homepage: http://localhost:5173
# - Produits: http://localhost:5173/products
# - Panier: http://localhost:5173/cart
# - Checkout: http://localhost:5173/checkout
# - Admin: http://localhost:5173/admin/dashboard# 1. Démarrer le tracking
cd web-site
node heatmap-api.mjs &
npm run dev
# 2. Utiliser l'application normalement (collecter des données)
# 3. Générer un rapport quotidien
python heatmap_plot.py --api
python generate_ux_report_local.py \
--json heatmap-data.json \
--image heatmap.png \
--output "reports/daily_report.pdf"
# 4. Analyser le rapport et implémenter les changements
# 5. Effacer les données pour le prochain cycle (optionnel)
# Dans la console navigateur: window.clearAll()# Build pour production
cd marketplace-hub
npm run build
# Output dans dist/
# Déployer dist/ sur n'importe quel hébergement statique (Vercel, Netlify, etc.)
# Pour l'API heatmap, déployer heatmap-api.mjs sur un serveur Node.js
# Mettre à jour tracking.js avec l'URL API de productionVariables d'environnement (créer .env dans marketplace-hub/):
VITE_API_URL=http://localhost:3001
VITE_ENABLE_TRACKING=trueConfiguration API Heatmap (heatmap-api.mjs):
const PORT = 3001; // Changer le port API
const CORS_ORIGIN = '*'; // Restreindre CORS en productionConfiguration Tracking (public/tracking.js):
const API_URL = 'http://localhost:3001/api/heatmap'; // URL production
const SYNC_INTERVAL = 5000; // Fréquence sync (millisecondes)