Eric2mangel commited on
Commit
ef8b14c
·
verified ·
1 Parent(s): 1d84261

Upload 2 files

Browse files
Files changed (1) hide show
  1. utils.py +35 -9
utils.py CHANGED
@@ -167,25 +167,51 @@ def calculer_benford_stats_et_graphique(data_a_tester, colonne_nom, N, html_outp
167
  html_output += "</div>"
168
 
169
  # Interprétation MAD compacte
170
- html_output += "<h3>📈 Qualité (MAD)</h3>"
171
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  if mad_value < 0.006:
173
  badge_style = "background: linear-gradient(135deg, #10b981, #059669); color: white;"
174
- mad_text = "EXCELLENTE"
175
  elif mad_value < 0.012:
176
  badge_style = "background: linear-gradient(135deg, #22c55e, #16a34a); color: white;"
177
- mad_text = "ACCEPTABLE"
178
  elif mad_value < 0.015:
179
  badge_style = "background: linear-gradient(135deg, #f59e0b, #d97706); color: white;"
180
- mad_text = "MARGINALE"
181
  elif mad_value < 0.020:
182
  badge_style = "background: linear-gradient(135deg, #f97316, #ea580c); color: white;"
183
- mad_text = "MODÉRÉE"
184
  else:
 
185
  badge_style = "background: linear-gradient(135deg, #ef4444, #dc2626); color: white;"
186
- mad_text = "FORTE"
187
-
188
- html_output += f"<span class='mad-badge' style='{badge_style}'>{mad_text}</span>"
 
 
189
 
190
  # Guide ultra-compact
191
  #html_output += "<div style='background: #f9fafb; padding: 10px; border-radius: 6px; margin-top: 10px; font-size: 12px;'>"
 
167
  html_output += "</div>"
168
 
169
  # Interprétation MAD compacte
170
+ # html_output += "<h3>📈 Qualité (MAD)</h3>"
171
+
172
+ # if mad_value < 0.006:
173
+ # badge_style = "background: linear-gradient(135deg, #10b981, #059669); color: white;"
174
+ # mad_text = "EXCELLENTE"
175
+ # elif mad_value < 0.012:
176
+ # badge_style = "background: linear-gradient(135deg, #22c55e, #16a34a); color: white;"
177
+ # mad_text = "ACCEPTABLE"
178
+ # elif mad_value < 0.015:
179
+ # badge_style = "background: linear-gradient(135deg, #f59e0b, #d97706); color: white;"
180
+ # mad_text = "MARGINALE"
181
+ # elif mad_value < 0.020:
182
+ # badge_style = "background: linear-gradient(135deg, #f97316, #ea580c); color: white;"
183
+ # mad_text = "MODÉRÉE"
184
+ # else:
185
+ # badge_style = "background: linear-gradient(135deg, #ef4444, #dc2626); color: white;"
186
+ # mad_text = "FORTE"
187
+
188
+ # html_output += f"<span class='mad-badge' style='{badge_style}'>{mad_text}</span>"
189
+
190
+
191
+ html_output += "<h3>🎯 Conformité MAD (Écart Absolu Moyen)</h3>"
192
+ html_output += "<p style='font-size: 0.9em; color: #555;'>Le MAD mesure l'écart moyen entre les fréquences observées et les fréquences théoriques de Benford. Plus le MAD est **petit**, plus la conformité est **forte**.</p>"
193
+
194
+ # Mise à jour des libellés pour indiquer la CONFORMITÉ (Inversé par rapport à la déviation)
195
  if mad_value < 0.006:
196
  badge_style = "background: linear-gradient(135deg, #10b981, #059669); color: white;"
197
+ mad_text = "EXCELLENTE CONFORMITÉ"
198
  elif mad_value < 0.012:
199
  badge_style = "background: linear-gradient(135deg, #22c55e, #16a34a); color: white;"
200
+ mad_text = "BONNE CONFORMITÉ"
201
  elif mad_value < 0.015:
202
  badge_style = "background: linear-gradient(135deg, #f59e0b, #d97706); color: white;"
203
+ mad_text = "CONFORMITÉ MARGINALE"
204
  elif mad_value < 0.020:
205
  badge_style = "background: linear-gradient(135deg, #f97316, #ea580c); color: white;"
206
+ mad_text = "FAIBLE CONFORMITÉ"
207
  else:
208
+ # Si le MAD est ≥ 0.020, la déviation est forte, donc la conformité est très faible/absente.
209
  badge_style = "background: linear-gradient(135deg, #ef4444, #dc2626); color: white;"
210
+ mad_text = "TRÈS FAIBLE CONFORMITÉ"
211
+
212
+ html_output += f"<div style='margin-top: 10px; font-size: 1.1em; font-weight: bold; padding: 10px; text-align: center; {badge_style}'>"
213
+ html_output += mad_text
214
+ html_output += "</div>"
215
 
216
  # Guide ultra-compact
217
  #html_output += "<div style='background: #f9fafb; padding: 10px; border-radius: 6px; margin-top: 10px; font-size: 12px;'>"