Commit ·
9e60540
1
Parent(s): 9c69672
Clarify metric descriptions and interpretation guidance
Browse files
src/credit_risk/app_support.py
CHANGED
|
@@ -164,15 +164,35 @@ def format_metrics_markdown(metrics: dict[str, float]) -> str:
|
|
| 164 |
|
| 165 |
lines = ["### Model Metrics"]
|
| 166 |
if "accuracy" in metrics:
|
| 167 |
-
lines.append(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
if "precision" in metrics:
|
| 169 |
-
lines.append(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
if "recall" in metrics:
|
| 171 |
-
lines.append(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
if "f1_score" in metrics:
|
| 173 |
-
lines.append(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
if "roc_auc" in metrics:
|
| 175 |
-
lines.append(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
return "\n".join(lines)
|
| 177 |
|
| 178 |
|
|
|
|
| 164 |
|
| 165 |
lines = ["### Model Metrics"]
|
| 166 |
if "accuracy" in metrics:
|
| 167 |
+
lines.append(
|
| 168 |
+
f"- **Accuracy (TP + TN) / (TP + TN + FP + FN):** {metrics['accuracy']:.4f} \n"
|
| 169 |
+
" Proportion of correct predictions among all predictions. "
|
| 170 |
+
"The closer to 1.0 (100%), the better."
|
| 171 |
+
)
|
| 172 |
if "precision" in metrics:
|
| 173 |
+
lines.append(
|
| 174 |
+
f"- **Precision TP / (TP + FP):** {metrics['precision']:.4f} \n"
|
| 175 |
+
" Among predicted positives, how many are truly positive. "
|
| 176 |
+
"The closer to 1.0 (100%), the better."
|
| 177 |
+
)
|
| 178 |
if "recall" in metrics:
|
| 179 |
+
lines.append(
|
| 180 |
+
f"- **Recall TP / (TP + FN):** {metrics['recall']:.4f} \n"
|
| 181 |
+
" Among actual positives, how many the model correctly identifies. "
|
| 182 |
+
"The closer to 1.0 (100%), the better."
|
| 183 |
+
)
|
| 184 |
if "f1_score" in metrics:
|
| 185 |
+
lines.append(
|
| 186 |
+
f"- **F1 Score 2 * (Precision * Recall) / (Precision + Recall):** {metrics['f1_score']:.4f} \n"
|
| 187 |
+
" Harmonic mean of Precision and Recall, useful when you need balance between both. "
|
| 188 |
+
"The closer to 1.0 (100%), the better."
|
| 189 |
+
)
|
| 190 |
if "roc_auc" in metrics:
|
| 191 |
+
lines.append(
|
| 192 |
+
f"- **ROC AUC (Area Under ROC Curve):** {metrics['roc_auc']:.4f} \n"
|
| 193 |
+
" Measures how well the model separates positive and negative classes across thresholds. "
|
| 194 |
+
"0.5 is random-like performance; the closer to 1.0, the better."
|
| 195 |
+
)
|
| 196 |
return "\n".join(lines)
|
| 197 |
|
| 198 |
|