ASI-Engineer commited on
Commit
c77c313
ยท
verified ยท
1 Parent(s): bb20631

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. exemples/demo_unitaire.py +129 -87
  2. exemples/demo_unitaire_hf.py +167 -108
exemples/demo_unitaire.py CHANGED
@@ -1,6 +1,6 @@
1
  #!/usr/bin/env python3
2
  """
3
- ๐Ÿ”ฎ Prรฉdiction UNITAIRE - Le plus simple possible
4
 
5
  Usage: python demo_unitaire.py
6
  """
@@ -10,71 +10,109 @@ import requests
10
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
11
  # CONFIGURATION
12
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
 
13
 
14
- # Pour utiliser l'API Hugging Face Spaces, changez l'URL ci-dessous
15
- # API_URL = "https://asi-engineer-oc-p5.hf.space"
16
- API_URL = "http://127.0.0.1:7860" # API locale par dรฉfaut
17
- API_KEY = None # Pas besoin d'API key en mode DEBUG local
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  print("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—")
20
  print("โ•‘ ๐Ÿ”ฎ PRร‰DICTION UNITAIRE - Risque de dรฉpart employรฉ โ•‘")
 
21
  print("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n")
22
 
23
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
24
- # COLLECTE DES DONNร‰ES
25
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
26
 
27
- print("Veuillez renseigner les informations de l'employรฉ:\n")
28
-
29
- # === SONDAGE ===
30
  print("๐Ÿ“‹ DONNร‰ES SONDAGE")
31
- nombre_participation_pee = int(input("Nombre participations PEE (0-3): "))
32
- nb_formations_suivies = int(input("Nombre formations suivies (0-6): "))
33
- distance_domicile_travail = int(input("Distance domicile-travail en km (1-30): "))
34
- niveau_education = int(input("Niveau d'รฉducation (1-5): "))
35
- domaine_etude = input(
36
- "Domaine d'รฉtude (Infra & Cloud, Transformation Digitale, Marketing, Entrepreunariat, Ressources Humaines, Autre): "
37
- )
38
- ayant_enfants = input("A des enfants? (Y/N): ").upper()
39
- frequence_deplacement = input("Frรฉquence dรฉplacement (Aucun, Occasionnel, Frequent): ")
40
- annees_depuis_la_derniere_promotion = int(input("Annรฉes depuis derniรจre promotion: "))
41
- annes_sous_responsable_actuel = int(input("Annรฉes sous responsable actuel (0-17): "))
42
-
43
- # === ร‰VALUATION ===
44
- print("\n๐Ÿ“Š DONNร‰ES ร‰VALUATION")
45
- satisfaction_employee_environnement = int(input("Satisfaction environnement (1-4): "))
46
- note_evaluation_precedente = int(input("Note รฉvaluation prรฉcรฉdente (1-4): "))
47
- niveau_hierarchique_poste = int(input("Niveau hiรฉrarchique (1-5): "))
48
- satisfaction_employee_nature_travail = int(input("Satisfaction nature travail (1-4): "))
49
- satisfaction_employee_equipe = int(input("Satisfaction รฉquipe (1-4): "))
50
- satisfaction_employee_equilibre_pro_perso = int(
51
- input("Satisfaction รฉquilibre pro/perso (1-4): ")
52
- )
53
- note_evaluation_actuelle = int(input("Note รฉvaluation actuelle (3-4): "))
54
- heure_supplementaires = input("Heures supplรฉmentaires? (Oui/Non): ")
55
- augementation_salaire_precedente = float(
56
- input("Augmentation salaire prรฉcรฉdente en % (0-100): ")
57
  )
58
 
59
- # === SIRH ===
60
- print("\n๐Ÿ’ผ DONNร‰ES RH")
61
- age = int(input("ร‚ge (18-60): "))
62
- genre = input("Genre (M/F): ").upper()
63
- revenu_mensuel = float(input("Revenu mensuel en โ‚ฌ (1000-20000): "))
64
- statut_marital = input("Statut marital (Cรฉlibataire, Mariรฉ(e), Divorcรฉ(e)): ")
65
- departement = input("Dรฉpartement (Commercial, Consulting, Ressources Humaines): ")
66
- poste = input(
67
- "Poste (Cadre Commercial, Assistant de Direction, Consultant, Tech Lead, Manager, Senior Manager, Reprรฉsentant Commercial, Directeur Technique, Ressources Humaines): "
68
- )
69
- nombre_experiences_precedentes = int(input("Nombre expรฉriences prรฉcรฉdentes (0-9): "))
70
- annee_experience_totale = int(input("Annรฉes expรฉrience totale: "))
71
- annees_dans_l_entreprise = int(input("Annรฉes dans l'entreprise (0-40): "))
72
- annees_dans_le_poste_actuel = int(input("Annรฉes dans le poste actuel (0-18): "))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
75
- # PRร‰DICTION
76
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
77
-
78
  employee_data = {
79
  "nombre_participation_pee": nombre_participation_pee,
80
  "nb_formations_suivies": nb_formations_suivies,
@@ -84,63 +122,67 @@ employee_data = {
84
  "domaine_etude": domaine_etude,
85
  "ayant_enfants": ayant_enfants,
86
  "frequence_deplacement": frequence_deplacement,
87
- "annees_depuis_la_derniere_promotion": annees_depuis_la_derniere_promotion,
88
- "annes_sous_responsable_actuel": annes_sous_responsable_actuel,
89
- "satisfaction_employee_environnement": satisfaction_employee_environnement,
90
- "note_evaluation_precedente": note_evaluation_precedente,
91
- "niveau_hierarchique_poste": niveau_hierarchique_poste,
92
- "satisfaction_employee_nature_travail": satisfaction_employee_nature_travail,
93
- "satisfaction_employee_equipe": satisfaction_employee_equipe,
94
- "satisfaction_employee_equilibre_pro_perso": satisfaction_employee_equilibre_pro_perso,
95
- "note_evaluation_actuelle": note_evaluation_actuelle,
96
  "heure_supplementaires": heure_supplementaires,
97
- "augementation_salaire_precedente": augementation_salaire_precedente,
98
  "age": age,
99
  "genre": genre,
100
  "revenu_mensuel": revenu_mensuel,
101
  "statut_marital": statut_marital,
102
  "departement": departement,
103
  "poste": poste,
104
- "nombre_experiences_precedentes": nombre_experiences_precedentes,
105
  "nombre_heures_travailless": 80,
106
- "annee_experience_totale": annee_experience_totale,
107
- "annees_dans_l_entreprise": annees_dans_l_entreprise,
108
- "annees_dans_le_poste_actuel": annees_dans_le_poste_actuel,
109
  }
110
 
111
- print("\nโณ Envoi de la requรชte ร  l'API...")
112
-
113
- headers = {"Content-Type": "application/json"}
114
- if API_KEY:
115
- headers["X-API-Key"] = API_KEY
116
 
117
  try:
118
  response = requests.post(
119
- f"{API_URL}/predict", json=employee_data, headers=headers, timeout=30
 
 
 
120
  )
121
  response.raise_for_status()
122
  result = response.json()
123
 
124
- # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
125
- # AFFICHAGE DU Rร‰SULTAT
126
- # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
127
-
128
  print("\n" + "โ•" * 60)
129
- print(" ๐Ÿ“Š Rร‰SULTAT")
130
  print("โ•" * 60)
131
 
132
- if result["prediction"] == 1:
133
- print("\n๐Ÿƒ PRร‰DICTION: L'EMPLOYร‰ VA QUITTER L'ENTREPRISE")
 
 
 
 
 
134
  else:
135
- print("\nโœ… PRร‰DICTION: L'EMPLOYร‰ VA RESTER")
136
 
137
- print(f"\n๐ŸŽฏ Niveau de risque: {result['risk_level']}")
138
- print(f" Probabilitรฉ de rester: {result['probability_0']:.1%}")
139
- print(f" Probabilitรฉ de partir: {result['probability_1']:.1%}")
140
 
141
- print("\n" + "โ•" * 60)
 
142
 
143
- except requests.exceptions.RequestException as e:
144
- print(f"\nโŒ ERREUR: {e}")
145
- if hasattr(e, "response") and e.response is not None:
146
- print(f"Dรฉtails: {e.response.text}")
 
 
1
  #!/usr/bin/env python3
2
  """
3
+ ๐Ÿ”ฎ Prรฉdiction UNITAIRE - Interface simple avec entrรฉes numรฉriques uniquement
4
 
5
  Usage: python demo_unitaire.py
6
  """
 
10
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
11
  # CONFIGURATION
12
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
13
+ API_URL = "http://127.0.0.1:7860" # API locale
14
 
15
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
16
+ # OPTIONS ร€ AFFICHER (pour rรฉfรฉrence utilisateur)
17
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
18
+ DOMAINES = {
19
+ 1: "Infra & Cloud",
20
+ 2: "Transformation Digitale",
21
+ 3: "Marketing",
22
+ 4: "Entrepreunariat",
23
+ 5: "Ressources Humaines",
24
+ 6: "Autre",
25
+ }
26
+ FREQUENCES = {1: "Aucun", 2: "Occasionnel", 3: "Frequent"}
27
+ STATUTS = {1: "Cรฉlibataire", 2: "Mariรฉ(e)", 3: "Divorcรฉ(e)"}
28
+ DEPARTEMENTS = {1: "Commercial", 2: "Consulting", 3: "Ressources Humaines"}
29
+ POSTES = {
30
+ 1: "Cadre Commercial",
31
+ 2: "Assistant de Direction",
32
+ 3: "Consultant",
33
+ 4: "Tech Lead",
34
+ 5: "Manager",
35
+ 6: "Senior Manager",
36
+ 7: "Reprรฉsentant Commercial",
37
+ 8: "Directeur Technique",
38
+ 9: "Ressources Humaines",
39
+ }
40
 
41
  print("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—")
42
  print("โ•‘ ๐Ÿ”ฎ PRร‰DICTION UNITAIRE - Risque de dรฉpart employรฉ โ•‘")
43
+ print("โ•‘ (API locale - Entrรฉes numรฉriques uniquement) โ•‘")
44
  print("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n")
45
 
46
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
47
+ # COLLECTE DES DONNร‰ES - Tout en nombres !
48
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
49
 
50
+ print("โ•" * 60)
 
 
51
  print("๐Ÿ“‹ DONNร‰ES SONDAGE")
52
+ print("โ•" * 60)
53
+ nombre_participation_pee = int(input("Participations PEE [0-3]: "))
54
+ nb_formations_suivies = int(input("Formations suivies [0-6]: "))
55
+ distance_domicile_travail = int(input("Distance domicile-travail km [1-30]: "))
56
+ niveau_education = int(
57
+ input("Niveau รฉducation [1=Bac, 2=Bac+2, 3=Licence, 4=Master, 5=Doctorat]: ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  )
59
 
60
+ print(f"\nDomaine d'รฉtude: {DOMAINES}")
61
+ domaine_choix = int(input("Choix [1-6]: "))
62
+ domaine_etude = DOMAINES.get(domaine_choix, "Autre")
63
+
64
+ ayant_enfants_choix = int(input("A des enfants? [0=Non, 1=Oui]: "))
65
+ ayant_enfants = "Y" if ayant_enfants_choix == 1 else "N"
66
+
67
+ print(f"\nFrรฉquence dรฉplacement: {FREQUENCES}")
68
+ freq_choix = int(input("Choix [1-3]: "))
69
+ frequence_deplacement = FREQUENCES.get(freq_choix, "Aucun")
70
+
71
+ annees_depuis_promo = int(input("Annรฉes depuis derniรจre promotion [0-15]: "))
72
+ annees_sous_responsable = int(input("Annรฉes sous responsable actuel [0-17]: "))
73
+
74
+ print("\n" + "โ•" * 60)
75
+ print("๐Ÿ“Š DONNร‰ES ร‰VALUATION")
76
+ print("โ•" * 60)
77
+ satisfaction_environnement = int(input("Satisfaction environnement [1-4]: "))
78
+ note_eval_precedente = int(input("Note รฉvaluation prรฉcรฉdente [1-4]: "))
79
+ niveau_hierarchique = int(input("Niveau hiรฉrarchique [1-5]: "))
80
+ satisfaction_travail = int(input("Satisfaction nature travail [1-4]: "))
81
+ satisfaction_equipe = int(input("Satisfaction รฉquipe [1-4]: "))
82
+ satisfaction_equilibre = int(input("Satisfaction รฉquilibre pro/perso [1-4]: "))
83
+ note_eval_actuelle = int(input("Note รฉvaluation actuelle [3-4]: "))
84
+ heures_sup_choix = int(input("Heures supplรฉmentaires? [0=Non, 1=Oui]: "))
85
+ heure_supplementaires = "Oui" if heures_sup_choix == 1 else "Non"
86
+ augmentation_salaire = float(input("Augmentation salaire prรฉcรฉdente % [0-25]: "))
87
+
88
+ print("\n" + "โ•" * 60)
89
+ print("๐Ÿ’ผ DONNร‰ES RH (SIRH)")
90
+ print("โ•" * 60)
91
+ age = int(input("ร‚ge [18-60]: "))
92
+ genre_choix = int(input("Genre [1=Homme, 2=Femme]: "))
93
+ genre = "M" if genre_choix == 1 else "F"
94
+ revenu_mensuel = float(input("Revenu mensuel โ‚ฌ [1000-20000]: "))
95
+
96
+ print(f"\nStatut marital: {STATUTS}")
97
+ statut_choix = int(input("Choix [1-3]: "))
98
+ statut_marital = STATUTS.get(statut_choix, "Cรฉlibataire")
99
+
100
+ print(f"\nDรฉpartement: {DEPARTEMENTS}")
101
+ dept_choix = int(input("Choix [1-3]: "))
102
+ departement = DEPARTEMENTS.get(dept_choix, "Commercial")
103
+
104
+ print(f"\nPoste: {POSTES}")
105
+ poste_choix = int(input("Choix [1-9]: "))
106
+ poste = POSTES.get(poste_choix, "Consultant")
107
+
108
+ nombre_exp_precedentes = int(input("Expรฉriences prรฉcรฉdentes [0-9]: "))
109
+ annees_exp_totale = int(input("Annรฉes expรฉrience totale [0-40]: "))
110
+ annees_entreprise = int(input("Annรฉes dans l'entreprise [0-40]: "))
111
+ annees_poste = int(input("Annรฉes dans le poste actuel [0-18]: "))
112
 
113
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
114
+ # CONSTRUCTION DE LA REQUรŠTE
115
  # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
 
116
  employee_data = {
117
  "nombre_participation_pee": nombre_participation_pee,
118
  "nb_formations_suivies": nb_formations_suivies,
 
122
  "domaine_etude": domaine_etude,
123
  "ayant_enfants": ayant_enfants,
124
  "frequence_deplacement": frequence_deplacement,
125
+ "annees_depuis_la_derniere_promotion": annees_depuis_promo,
126
+ "annes_sous_responsable_actuel": annees_sous_responsable,
127
+ "satisfaction_employee_environnement": satisfaction_environnement,
128
+ "note_evaluation_precedente": note_eval_precedente,
129
+ "niveau_hierarchique_poste": niveau_hierarchique,
130
+ "satisfaction_employee_nature_travail": satisfaction_travail,
131
+ "satisfaction_employee_equipe": satisfaction_equipe,
132
+ "satisfaction_employee_equilibre_pro_perso": satisfaction_equilibre,
133
+ "note_evaluation_actuelle": note_eval_actuelle,
134
  "heure_supplementaires": heure_supplementaires,
135
+ "augementation_salaire_precedente": augmentation_salaire,
136
  "age": age,
137
  "genre": genre,
138
  "revenu_mensuel": revenu_mensuel,
139
  "statut_marital": statut_marital,
140
  "departement": departement,
141
  "poste": poste,
142
+ "nombre_experiences_precedentes": nombre_exp_precedentes,
143
  "nombre_heures_travailless": 80,
144
+ "annee_experience_totale": annees_exp_totale,
145
+ "annees_dans_l_entreprise": annees_entreprise,
146
+ "annees_dans_le_poste_actuel": annees_poste,
147
  }
148
 
149
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
150
+ # PRร‰DICTION
151
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
152
+ print("\nโณ Envoi de la requรชte ร  l'API locale...")
 
153
 
154
  try:
155
  response = requests.post(
156
+ f"{API_URL}/predict",
157
+ json=employee_data,
158
+ headers={"Content-Type": "application/json"},
159
+ timeout=30,
160
  )
161
  response.raise_for_status()
162
  result = response.json()
163
 
 
 
 
 
164
  print("\n" + "โ•" * 60)
165
+ print("๐Ÿ“Š Rร‰SULTAT DE LA PRร‰DICTION")
166
  print("โ•" * 60)
167
 
168
+ prediction = result.get("prediction", "N/A")
169
+ prob_stay = result.get("probability_stay", 0) * 100
170
+ prob_leave = result.get("probability_leave", 0) * 100
171
+ risk = result.get("risk_level", "N/A")
172
+
173
+ if prediction == 1:
174
+ print("\n๐Ÿšจ PRร‰DICTION: VA PARTIR")
175
  else:
176
+ print("\nโœ… PRร‰DICTION: VA RESTER")
177
 
178
+ print(f"\n๐Ÿ“ˆ Probabilitรฉ de rester: {prob_stay:.1f}%")
179
+ print(f"๐Ÿ“‰ Probabilitรฉ de partir: {prob_leave:.1f}%")
 
180
 
181
+ risk_emoji = {"Low": "๐ŸŸข", "Medium": "๐ŸŸ ", "High": "๐Ÿ”ด"}.get(risk, "โšช")
182
+ print(f"\n{risk_emoji} Niveau de risque: {risk}")
183
 
184
+ except requests.exceptions.ConnectionError:
185
+ print("\nโŒ Impossible de se connecter ร  l'API locale.")
186
+ print(" Lancez d'abord: ./lancer_api.sh")
187
+ except Exception as e:
188
+ print(f"\nโŒ Erreur: {e}")
exemples/demo_unitaire_hf.py CHANGED
@@ -1,131 +1,190 @@
1
  #!/usr/bin/env python3
2
  """
3
- ๐Ÿ”ฎ Prรฉdiction UNITAIRE via API Hugging Face
4
 
5
  Usage: python demo_unitaire_hf.py
6
- - Pose des questions interactives
7
- - Envoie la requรชte ร  la Space HF
8
- - Affiche la prรฉdiction
9
-
10
- Option: dรฉfinir HF_API_URL pour surcharger l'URL par dรฉfaut.
11
  """
12
 
13
  import os
14
- import requests
 
 
 
 
 
 
 
15
 
16
  API_URL = os.getenv("HF_API_URL", "https://asi-engineer-oc-p5.hf.space")
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  print("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—")
19
- print("โ•‘ ๐Ÿ”ฎ Prรฉdiction UNITAIRE - API Hugging Face โ•‘")
 
20
  print("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n")
21
  print(f"๐ŸŒ API: {API_URL}\n")
22
 
23
- # Collecte minimaliste des champs requis
24
- print("Veuillez renseigner les informations de l'employรฉ:\n")
 
25
 
26
- # === SONDAGE ===
27
- nombre_participation_pee = int(input("Nombre participations PEE (0-3): "))
28
- nb_formations_suivies = int(input("Nombre formations suivies (0-6): "))
29
- distance_domicile_travail = int(input("Distance domicile-travail (1-30): "))
30
- niveau_education = int(input("Niveau d'รฉducation (1-5): "))
31
- domaine_etude = input(
32
- "Domaine d'รฉtude: (Infra & Cloud, Transformation Digitale, Marketing, Entrepreunariat, Ressources Humaines, Autre): "
33
- )
34
- ayant_enfants = input("A des enfants? (Y/N): ").upper()
35
- frequence_deplacement = input("Frรฉquence dรฉplacement (Aucun, Occasionnel, Frequent): ")
36
- annees_depuis_la_derniere_promotion = int(input("Annรฉes depuis derniรจre promotion: "))
37
- annes_sous_responsable_actuel = int(input("Annรฉes sous responsable actuel (0-17): "))
38
-
39
- # === ร‰VALUATION ===
40
- satisfaction_employee_environnement = int(input("Satisfaction environnement (1-4): "))
41
- note_evaluation_precedente = int(input("Note รฉvaluation prรฉcรฉdente (1-4): "))
42
- niveau_hierarchique_poste = int(input("Niveau hiรฉrarchique (1-5): "))
43
- satisfaction_employee_nature_travail = int(input("Satisfaction nature travail (1-4): "))
44
- satisfaction_employee_equipe = int(input("Satisfaction รฉquipe (1-4): "))
45
- satisfaction_employee_equilibre_pro_perso = int(
46
- input("Satisfaction รฉquilibre pro/perso (1-4): ")
47
  )
48
- note_evaluation_actuelle = int(input("Note รฉvaluation actuelle (3-4): "))
49
- heure_supplementaires = input("Heures supplรฉmentaires? (Oui/Non): ")
50
- augementation_salaire_precedente = float(input("Augmentation salaire prรฉcรฉdente (%): "))
51
-
52
- # === SIRH ===
53
- age = int(input("ร‚ge (18-60): "))
54
- genre = input("Genre (M/F): ").upper()
55
- revenu_mensuel = float(input("Revenu mensuel (โ‚ฌ): "))
56
- statut_marital = input("Statut marital (Cรฉlibataire, Mariรฉ(e), Divorcรฉ(e)): ")
57
- departement = input("Dรฉpartement (Commercial, Consulting, Ressources Humaines): ")
58
- poste = input("Poste: ")
59
- nombre_experiences_precedentes = int(input("Nb expรฉriences prรฉcรฉdentes (0-9): "))
60
- annee_experience_totale = int(input("Annรฉes expรฉrience totale: "))
61
- annees_dans_l_entreprise = int(input("Annรฉes dans l'entreprise (0-40): "))
62
- annees_dans_le_poste_actuel = int(input("Annรฉes dans le poste actuel (0-18): "))
63
-
64
- employee_data = {
65
- "nombre_participation_pee": nombre_participation_pee,
66
- "nb_formations_suivies": nb_formations_suivies,
67
- "nombre_employee_sous_responsabilite": 1,
68
- "distance_domicile_travail": distance_domicile_travail,
69
- "niveau_education": niveau_education,
70
- "domaine_etude": domaine_etude,
71
- "ayant_enfants": ayant_enfants,
72
- "frequence_deplacement": frequence_deplacement,
73
- "annees_depuis_la_derniere_promotion": annees_depuis_la_derniere_promotion,
74
- "annes_sous_responsable_actuel": annes_sous_responsable_actuel,
75
- "satisfaction_employee_environnement": satisfaction_employee_environnement,
76
- "note_evaluation_precedente": note_evaluation_precedente,
77
- "niveau_hierarchique_poste": niveau_hierarchique_poste,
78
- "satisfaction_employee_nature_travail": satisfaction_employee_nature_travail,
79
- "satisfaction_employee_equipe": satisfaction_employee_equipe,
80
- "satisfaction_employee_equilibre_pro_perso": satisfaction_employee_equilibre_pro_perso,
81
- "note_evaluation_actuelle": note_evaluation_actuelle,
82
- "heure_supplementaires": heure_supplementaires,
83
- "augementation_salaire_precedente": augementation_salaire_precedente,
84
- "age": age,
85
- "genre": genre,
86
- "revenu_mensuel": revenu_mensuel,
87
- "statut_marital": statut_marital,
88
- "departement": departement,
89
- "poste": poste,
90
- "nombre_experiences_precedentes": nombre_experiences_precedentes,
91
- "nombre_heures_travailless": 80,
92
- "annee_experience_totale": annee_experience_totale,
93
- "annees_dans_l_entreprise": annees_dans_l_entreprise,
94
- "annees_dans_le_poste_actuel": annees_dans_le_poste_actuel,
95
- }
96
 
97
- print("\nโณ Envoi de la requรชte ร  l'API HF...")
98
- headers = {"Content-Type": "application/json"}
99
- # Optionnel: API Key si la Space protรจge les endpoints
100
- api_key = os.getenv("HF_API_KEY")
101
- if api_key:
102
- headers["X-API-Key"] = api_key
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  try:
105
- r = requests.post(
106
- f"{API_URL}/predict", json=employee_data, headers=headers, timeout=45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  )
108
- if r.status_code == 404:
109
- print(
110
- "\nโŒ Endpoint HF introuvable (/predict). Vรฉrifiez que la Space expose l'API FastAPI."
111
- )
112
- print(" Sinon, utilisez l'API locale (lancer_api.sh) ou GRADIO.")
113
- raise SystemExit(1)
114
- r.raise_for_status()
115
- result = r.json()
116
 
117
  print("\n" + "โ•" * 60)
118
- print(" ๐Ÿ“Š Rร‰SULTAT (HF)")
119
  print("โ•" * 60)
120
- print(
121
- "\nโœ… PRร‰DICTION: "
122
- + ("VA RESTER" if result.get("prediction", 0) == 0 else "VA PARTIR")
123
- )
124
- print(f"๐ŸŽฏ Niveau de risque: {result.get('risk_level')}")
125
- print(f" Prob rester: {result.get('probability_0', 0):.1%}")
126
- print(f" Prob partir: {result.get('probability_1', 0):.1%}")
127
-
128
- except requests.exceptions.RequestException as e:
129
- print(f"\nโŒ ERREUR API HF: {e}")
130
- if getattr(e, "response", None) is not None:
131
- print(f"Dรฉtails: {e.response.text}")
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #!/usr/bin/env python3
2
  """
3
+ ๐Ÿ”ฎ Prรฉdiction UNITAIRE via Hugging Face - Entrรฉes numรฉriques uniquement
4
 
5
  Usage: python demo_unitaire_hf.py
6
+ Prรฉrequis: pip install gradio_client
 
 
 
 
7
  """
8
 
9
  import os
10
+ import sys
11
+
12
+ try:
13
+ from gradio_client import Client
14
+ except ImportError:
15
+ print("โŒ gradio_client non installรฉ. Installez-le avec:")
16
+ print(" pip install gradio_client")
17
+ sys.exit(1)
18
 
19
  API_URL = os.getenv("HF_API_URL", "https://asi-engineer-oc-p5.hf.space")
20
 
21
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
22
+ # OPTIONS ร€ AFFICHER (pour rรฉfรฉrence utilisateur)
23
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
24
+ DOMAINES = {
25
+ 1: "Infra & Cloud",
26
+ 2: "Transformation Digitale",
27
+ 3: "Marketing",
28
+ 4: "Entrepreunariat",
29
+ 5: "Ressources Humaines",
30
+ 6: "Autre",
31
+ }
32
+ FREQUENCES = {1: "Aucun", 2: "Occasionnel", 3: "Frequent"}
33
+ STATUTS = {1: "Cรฉlibataire", 2: "Mariรฉ(e)", 3: "Divorcรฉ(e)"}
34
+ DEPARTEMENTS = {1: "Commercial", 2: "Consulting", 3: "Ressources Humaines"}
35
+ POSTES = {
36
+ 1: "Cadre Commercial",
37
+ 2: "Assistant de Direction",
38
+ 3: "Consultant",
39
+ 4: "Tech Lead",
40
+ 5: "Manager",
41
+ 6: "Senior Manager",
42
+ 7: "Reprรฉsentant Commercial",
43
+ 8: "Directeur Technique",
44
+ 9: "Ressources Humaines",
45
+ }
46
+
47
  print("โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—")
48
+ print("โ•‘ ๐Ÿ”ฎ PRร‰DICTION UNITAIRE - Hugging Face Spaces โ•‘")
49
+ print("โ•‘ (Entrรฉes numรฉriques uniquement) โ•‘")
50
  print("โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n")
51
  print(f"๐ŸŒ API: {API_URL}\n")
52
 
53
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
54
+ # COLLECTE DES DONNร‰ES - Tout en nombres !
55
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
56
 
57
+ print("โ•" * 60)
58
+ print("๐Ÿ“‹ DONNร‰ES SONDAGE")
59
+ print("โ•" * 60)
60
+ nombre_participation_pee = int(input("Participations PEE [0-3]: "))
61
+ nb_formations_suivies = int(input("Formations suivies [0-6]: "))
62
+ distance_domicile_travail = int(input("Distance domicile-travail km [1-30]: "))
63
+ niveau_education = int(
64
+ input("Niveau รฉducation [1=Bac, 2=Bac+2, 3=Licence, 4=Master, 5=Doctorat]: ")
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
+ print(f"\nDomaine d'รฉtude: {DOMAINES}")
68
+ domaine_choix = int(input("Choix [1-6]: "))
69
+ domaine_etude = DOMAINES.get(domaine_choix, "Autre")
70
+
71
+ ayant_enfants_choix = int(input("A des enfants? [0=Non, 1=Oui]: "))
72
+ ayant_enfants = "Y" if ayant_enfants_choix == 1 else "N"
73
+
74
+ print(f"\nFrรฉquence dรฉplacement: {FREQUENCES}")
75
+ freq_choix = int(input("Choix [1-3]: "))
76
+ frequence_deplacement = FREQUENCES.get(freq_choix, "Aucun")
77
+
78
+ annees_depuis_promo = int(input("Annรฉes depuis derniรจre promotion [0-15]: "))
79
+ annees_sous_responsable = int(input("Annรฉes sous responsable actuel [0-17]: "))
80
+
81
+ print("\n" + "โ•" * 60)
82
+ print("๐Ÿ“Š DONNร‰ES ร‰VALUATION")
83
+ print("โ•" * 60)
84
+ satisfaction_environnement = int(input("Satisfaction environnement [1-4]: "))
85
+ note_eval_precedente = int(input("Note รฉvaluation prรฉcรฉdente [1-4]: "))
86
+ niveau_hierarchique = int(input("Niveau hiรฉrarchique [1-5]: "))
87
+ satisfaction_travail = int(input("Satisfaction nature travail [1-4]: "))
88
+ satisfaction_equipe = int(input("Satisfaction รฉquipe [1-4]: "))
89
+ satisfaction_equilibre = int(input("Satisfaction รฉquilibre pro/perso [1-4]: "))
90
+ note_eval_actuelle = int(input("Note รฉvaluation actuelle [3-4]: "))
91
+ heures_sup_choix = int(input("Heures supplรฉmentaires? [0=Non, 1=Oui]: "))
92
+ heure_supplementaires = "Oui" if heures_sup_choix == 1 else "Non"
93
+ augmentation_salaire = float(input("Augmentation salaire prรฉcรฉdente % [0-25]: "))
94
+
95
+ print("\n" + "โ•" * 60)
96
+ print("๐Ÿ’ผ DONNร‰ES RH (SIRH)")
97
+ print("โ•" * 60)
98
+ age = int(input("ร‚ge [18-60]: "))
99
+ genre_choix = int(input("Genre [1=Homme, 2=Femme]: "))
100
+ genre = "M" if genre_choix == 1 else "F"
101
+ revenu_mensuel = float(input("Revenu mensuel โ‚ฌ [1000-20000]: "))
102
+
103
+ print(f"\nStatut marital: {STATUTS}")
104
+ statut_choix = int(input("Choix [1-3]: "))
105
+ statut_marital = STATUTS.get(statut_choix, "Cรฉlibataire")
106
+
107
+ print(f"\nDรฉpartement: {DEPARTEMENTS}")
108
+ dept_choix = int(input("Choix [1-3]: "))
109
+ departement = DEPARTEMENTS.get(dept_choix, "Commercial")
110
+
111
+ print(f"\nPoste: {POSTES}")
112
+ poste_choix = int(input("Choix [1-9]: "))
113
+ poste = POSTES.get(poste_choix, "Consultant")
114
+
115
+ nombre_exp_precedentes = int(input("Expรฉriences prรฉcรฉdentes [0-9]: "))
116
+ annees_exp_totale = int(input("Annรฉes expรฉrience totale [0-40]: "))
117
+ annees_entreprise = int(input("Annรฉes dans l'entreprise [0-40]: "))
118
+ annees_poste = int(input("Annรฉes dans le poste actuel [0-18]: "))
119
+
120
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
121
+ # PRร‰DICTION VIA GRADIO CLIENT
122
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•๏ฟฝ๏ฟฝโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
123
+ print("\nโณ Connexion ร  l'API Gradio HF...")
124
 
125
  try:
126
+ client = Client(API_URL)
127
+ print("โœ… Connectรฉ\n")
128
+ print("โณ Envoi de la prรฉdiction...")
129
+
130
+ result = client.predict(
131
+ nombre_participation_pee=nombre_participation_pee,
132
+ nb_formations_suivies=nb_formations_suivies,
133
+ nombre_employee_sous_responsabilite=1,
134
+ distance_domicile_travail=distance_domicile_travail,
135
+ niveau_education=niveau_education,
136
+ domaine_etude=domaine_etude,
137
+ ayant_enfants=ayant_enfants,
138
+ frequence_deplacement=frequence_deplacement,
139
+ annees_depuis_la_derniere_promotion=annees_depuis_promo,
140
+ annes_sous_responsable_actuel=annees_sous_responsable,
141
+ satisfaction_employee_environnement=satisfaction_environnement,
142
+ note_evaluation_precedente=note_eval_precedente,
143
+ niveau_hierarchique_poste=niveau_hierarchique,
144
+ satisfaction_employee_nature_travail=satisfaction_travail,
145
+ satisfaction_employee_equipe=satisfaction_equipe,
146
+ satisfaction_employee_equilibre_pro_perso=satisfaction_equilibre,
147
+ note_evaluation_actuelle=note_eval_actuelle,
148
+ heure_supplementaires=heure_supplementaires,
149
+ augementation_salaire_precedente=augmentation_salaire,
150
+ age=age,
151
+ genre=genre,
152
+ revenu_mensuel=revenu_mensuel,
153
+ statut_marital=statut_marital,
154
+ departement=departement,
155
+ poste=poste,
156
+ nombre_experiences_precedentes=nombre_exp_precedentes,
157
+ nombre_heures_travailless=80,
158
+ annee_experience_totale=annees_exp_totale,
159
+ annees_dans_l_entreprise=annees_entreprise,
160
+ annees_dans_le_poste_actuel=annees_poste,
161
+ api_name="/predict",
162
  )
 
 
 
 
 
 
 
 
163
 
164
  print("\n" + "โ•" * 60)
165
+ print("๐Ÿ“Š Rร‰SULTAT DE LA PRร‰DICTION (HF)")
166
  print("โ•" * 60)
167
+
168
+ # Le rรฉsultat Gradio peut รชtre un dict ou une string
169
+ if isinstance(result, dict):
170
+ prediction = result.get("prediction", "N/A")
171
+ prob_stay = result.get("probability_stay", 0) * 100
172
+ prob_leave = result.get("probability_leave", 0) * 100
173
+ risk = result.get("risk_level", "N/A")
174
+
175
+ if prediction == 1:
176
+ print("\n๐Ÿšจ PRร‰DICTION: VA PARTIR")
177
+ else:
178
+ print("\nโœ… PRร‰DICTION: VA RESTER")
179
+
180
+ print(f"\n๐Ÿ“ˆ Probabilitรฉ de rester: {prob_stay:.1f}%")
181
+ print(f"๐Ÿ“‰ Probabilitรฉ de partir: {prob_leave:.1f}%")
182
+
183
+ risk_emoji = {"Low": "๐ŸŸข", "Medium": "๐ŸŸ ", "High": "๐Ÿ”ด"}.get(risk, "โšช")
184
+ print(f"\n{risk_emoji} Niveau de risque: {risk}")
185
+ else:
186
+ print(f"\n๐Ÿ“‹ Rรฉsultat: {result}")
187
+
188
+ except Exception as e:
189
+ print(f"\nโŒ Erreur: {e}")
190
+ sys.exit(1)