marcilioduarte commited on
Commit
9c69672
·
1 Parent(s): 3c9829c

Enhance metric section with formulas in Gradio app

Browse files
Files changed (1) hide show
  1. src/credit_risk/app_support.py +10 -3
src/credit_risk/app_support.py CHANGED
@@ -163,9 +163,16 @@ def format_metrics_markdown(metrics: dict[str, float]) -> str:
163
  return "Metrics not available. Run `python scripts/train_model.py` first."
164
 
165
  lines = ["### Model Metrics"]
166
- for key, value in metrics.items():
167
- metric_name = key.replace("_", " ").title()
168
- lines.append(f"- **{metric_name}:** {value:.4f}")
 
 
 
 
 
 
 
169
  return "\n".join(lines)
170
 
171
 
 
163
  return "Metrics not available. Run `python scripts/train_model.py` first."
164
 
165
  lines = ["### Model Metrics"]
166
+ if "accuracy" in metrics:
167
+ lines.append(f"- **Accuracy (TP + TN) / (TP + TN + FP + FN):** {metrics['accuracy']:.4f}")
168
+ if "precision" in metrics:
169
+ lines.append(f"- **Precision TP / (TP + FP):** {metrics['precision']:.4f}")
170
+ if "recall" in metrics:
171
+ lines.append(f"- **Recall TP / (TP + FN):** {metrics['recall']:.4f}")
172
+ if "f1_score" in metrics:
173
+ lines.append(f"- **F1 Score 2 * (Precision * Recall) / (Precision + Recall):** {metrics['f1_score']:.4f}")
174
+ if "roc_auc" in metrics:
175
+ lines.append(f"- **ROC AUC (Area Under ROC Curve):** {metrics['roc_auc']:.4f}")
176
  return "\n".join(lines)
177
 
178