Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- README_HF.md +106 -0
README_HF.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Employee Turnover Prediction API
|
| 3 |
+
emoji: 👔
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: true
|
| 8 |
+
license: mit
|
| 9 |
+
app_port: 7860
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# Employee Turnover Prediction API 🚀 (v3.2.1)
|
| 14 |
+
|
| 15 |
+
API de prédiction du turnover des employés (XGBoost + SMOTE) avec endpoints batch, validation stricte et documentation à jour.
|
| 16 |
+
|
| 17 |
+
## 🎯 Fonctionnalités
|
| 18 |
+
|
| 19 |
+
- ✅ Prédiction de turnover (0 = reste, 1 = part)
|
| 20 |
+
- 📦 Endpoint batch CSV (3 fichiers bruts)
|
| 21 |
+
- 🎛️ Sliders Gradio et schémas Pydantic alignés sur les min/max réels
|
| 22 |
+
- 📊 Probabilités et niveau de risque (Low/Medium/High)
|
| 23 |
+
- 🔐 Authentification API Key (obligatoire)
|
| 24 |
+
- 📝 Logs structurés JSON
|
| 25 |
+
- 🛡️ Rate limiting (20 req/min)
|
| 26 |
+
- 📚 Documentation OpenAPI/Swagger
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
## 🔗 Endpoints
|
| 30 |
+
|
| 31 |
+
| Endpoint | Description |
|
| 32 |
+
|----------|-------------|
|
| 33 |
+
| `/docs` | Documentation interactive Swagger |
|
| 34 |
+
| `/health` | Status de l'API |
|
| 35 |
+
| `/ui` | Interface Gradio interactive |
|
| 36 |
+
| `/predict` | Prédiction unitaire (JSON, contraintes réelles) |
|
| 37 |
+
| `/predict/batch` | Prédiction batch (3 fichiers CSV bruts) |
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
## 🚀 Utilisation
|
| 41 |
+
|
| 42 |
+
### Prédiction unitaire (toutes contraintes appliquées)
|
| 43 |
+
```bash
|
| 44 |
+
curl -X POST https://asi-engineer-oc-p5-dev.hf.space/predict \
|
| 45 |
+
-H "Content-Type: application/json" \
|
| 46 |
+
-H "X-API-Key: your-key" \
|
| 47 |
+
-d '{
|
| 48 |
+
"nombre_participation_pee": 0,
|
| 49 |
+
"nb_formations_suivies": 2,
|
| 50 |
+
"nombre_employee_sous_responsabilite": 1,
|
| 51 |
+
"distance_domicile_travail": 15,
|
| 52 |
+
"niveau_education": 3,
|
| 53 |
+
"domaine_etude": "Infra & Cloud",
|
| 54 |
+
"ayant_enfants": "Y",
|
| 55 |
+
"frequence_deplacement": "Occasionnel",
|
| 56 |
+
"annees_depuis_la_derniere_promotion": 2,
|
| 57 |
+
"annes_sous_responsable_actuel": 5,
|
| 58 |
+
"satisfaction_employee_environnement": 3,
|
| 59 |
+
"note_evaluation_precedente": 4,
|
| 60 |
+
"niveau_hierarchique_poste": 2,
|
| 61 |
+
"satisfaction_employee_nature_travail": 3,
|
| 62 |
+
"satisfaction_employee_equipe": 3,
|
| 63 |
+
"satisfaction_employee_equilibre_pro_perso": 2,
|
| 64 |
+
"note_evaluation_actuelle": 4,
|
| 65 |
+
"heure_supplementaires": "Non",
|
| 66 |
+
"augementation_salaire_precedente": 5.5,
|
| 67 |
+
"age": 35,
|
| 68 |
+
"genre": "M",
|
| 69 |
+
"revenu_mensuel": 4500.0,
|
| 70 |
+
"statut_marital": "Marié(e)",
|
| 71 |
+
"departement": "Commercial",
|
| 72 |
+
"poste": "Manager",
|
| 73 |
+
"nombre_experiences_precedentes": 3,
|
| 74 |
+
"nombre_heures_travailless": 80,
|
| 75 |
+
"annee_experience_totale": 10,
|
| 76 |
+
"annees_dans_l_entreprise": 5,
|
| 77 |
+
"annees_dans_le_poste_actuel": 2
|
| 78 |
+
}'
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### Prédiction batch (3 fichiers CSV bruts)
|
| 82 |
+
```bash
|
| 83 |
+
curl -X POST https://asi-engineer-oc-p5-dev.hf.space/predict/batch \
|
| 84 |
+
-H "X-API-Key: your-key" \
|
| 85 |
+
-F "sondage_file=@extrait_sondage.csv" \
|
| 86 |
+
-F "eval_file=@extrait_eval.csv" \
|
| 87 |
+
-F "sirh_file=@extrait_sirh.csv"
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
**Réponse :**
|
| 91 |
+
```json
|
| 92 |
+
{
|
| 93 |
+
"total_employees": 1470,
|
| 94 |
+
"predictions": [...],
|
| 95 |
+
"summary": {
|
| 96 |
+
"total_stay": 1169,
|
| 97 |
+
"total_leave": 301,
|
| 98 |
+
"high_risk_count": 222
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
## 📚 Documentation complète
|
| 105 |
+
|
| 106 |
+
Voir [docs/API.md](docs/API.md) ou le [GitHub Repository](https://github.com/chaton59/OC_P5) pour la documentation complète et les contraintes détaillées (min/max, enums, etc).
|