Print decision accuracy and confusion matrix metrics.
(stats: dict)
| 1068 | |
| 1069 | |
| 1070 | def _print_decision_stats(stats: dict) -> None: |
| 1071 | """Print decision accuracy and confusion matrix metrics.""" |
| 1072 | print(f"\n DECISION ACCURACY: {stats['decision_accuracy']:.1%}") |
| 1073 | dm = stats["decision_matrix"] |
| 1074 | print(f" TP={dm['TP']} FP={dm['FP']} FN={dm['FN']} TN={dm['TN']}") |
| 1075 | if dm["TP"] + dm["FP"] > 0: |
| 1076 | precision = dm["TP"] / (dm["TP"] + dm["FP"]) |
| 1077 | print(f" Precision: {precision:.3f}") |
| 1078 | if dm["TP"] + dm["FN"] > 0: |
| 1079 | recall = dm["TP"] / (dm["TP"] + dm["FN"]) |
| 1080 | print(f" Recall: {recall:.3f}") |
| 1081 | if dm["TP"] + dm["FP"] > 0 and dm["TP"] + dm["FN"] > 0: |
| 1082 | f1 = ( |
| 1083 | 2 * precision * recall / (precision + recall) |
| 1084 | if (precision + recall) > 0 |
| 1085 | else 0 |
| 1086 | ) |
| 1087 | print(f" F1 Score: {f1:.3f}") |
| 1088 | |
| 1089 | |
| 1090 | def _print_group_and_field_accuracy(stats: dict) -> None: |