@@ -68,8 +68,55 @@ def balanced_precision(self) -> float:
68
68
69
69
def summary (self ) -> str :
70
70
return f'''hits={ self .tp } correct denials={ self .tn } overpermission={ self ._fp } underpermission={ self .fn }
71
- precision={ self .precision ():.2} sensitivity={ self .sensitivity ():.2}
72
- f1={ self .f1 ():.2} f2={ self .f2 ():.2} fm={ self .fm ():.2} csi={ self .jaccard_index ():.2} '''
71
+ precision={ self .precision ():.3} sensitivity={ self .sensitivity ():.3}
72
+ f1={ self .f1 ():.3} f2={ self .f2 ():.3} fm={ self .fm ():.3} csi={ self .jaccard_index ():.3} '''
73
+
74
+ @staticmethod
75
+ def summary_csv_header () -> str :
76
+ """Return header line for csv file."""
77
+ return 'generalization,hits,correct denials,overpermission,underpermission,precision,sensitivity,f1,f2,fm,csi\n '
78
+
79
+ def summary_csv_line (self , generalization : str ) -> str :
80
+ """Return summary as a csv line."""
81
+ return f'{ generalization } ,{ self .tp } ,{ self .tn } ,{ self ._fp } ,{ self .fn } ,{ self .precision ():.4} ,{ self .sensitivity ():.4} ,{ self .f1 ():.4} ,{ self .f2 ():.4} ,{ self .fm ():.4} ,{ self .jaccard_index ():.4} \n '
82
+
83
+ @staticmethod
84
+ def summary_tabular_full_header () -> str :
85
+ return r'''\begin{table}[htbp]
86
+ \caption{}
87
+ \label{tab:}
88
+ \centering
89
+ \begin{tabular}[h]{@{}lrrrrrrrrrr@{}}
90
+ \toprule
91
+ Generalization & TP & TN & FP & FN & PPV & SEN & \(F_1\) & \(F_2\) & FM & CSI \\
92
+ \midrule
93
+ '''
94
+
95
+ @staticmethod
96
+ def summary_tabular_footer () -> str :
97
+ return ''' \\ bottomrule
98
+ \\ end{tabular}
99
+ \\ end{table}\n '''
100
+
101
+ def summary_tabular_full_line (self , generalization : str ) -> str :
102
+ """Return summary as a csv line."""
103
+ return f'{ generalization } \t &\t { self .tp } \t &\t { self .tn } \t &\t { self ._fp } \t &\t { self .fn } \t &\t { self .precision ():.4} \t &\t { self .sensitivity ():.4} \t &\t { self .f1 ():.4} \t &\t { self .f2 ():.4} \t &\t { self .fm ():.4} \t &\t { self .jaccard_index ():.4} \\ \\ \n '
104
+
105
+ @staticmethod
106
+ def summary_tabular_short_header () -> str :
107
+ return r'''\begin{table}[htbp]
108
+ \caption{}
109
+ \label{tab:}
110
+ \centering
111
+ \begin{tabular}[h]{@{}lrrr@{}}
112
+ \toprule
113
+ Generalization & \(F_2\) & SEN & PPV \\
114
+ \midrule
115
+ '''
116
+
117
+ def summary_tabular_short_line (self , generalization : str ) -> str :
118
+ """Return summary as a csv line."""
119
+ return f'{ generalization } \t &\t { self .sensitivity ():.4} \t &\t { self .precision ():.4} \t &\t { self .f2 ():.4} \\ \\ \n '
73
120
74
121
def __repr__ (self ) -> str :
75
122
return f'Result({ self .tp } , { self .tn } , { self ._fp } , { self ._fn } )'
0 commit comments