Prevented division by zero errors

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
2019-06-10 16:55:23 +02:00
parent ca90ea9f17
commit 4ccaad2ff0

View File

@ -296,7 +296,7 @@ def get_f1_score(cumulative_precisions: List[np.ndarray],
if not np.count_nonzero(cumulative_precision + cumulative_recall): if not np.count_nonzero(cumulative_precision + cumulative_recall):
cumulative_f1_scores.append([]) cumulative_f1_scores.append([])
continue continue
f1_score = 2 * ((cumulative_precision * cumulative_recall) / (cumulative_precision + cumulative_recall)) f1_score = 2 * ((cumulative_precision * cumulative_recall) / (cumulative_precision + cumulative_recall + 0.001))
cumulative_f1_scores.append(f1_score) cumulative_f1_scores.append(f1_score)
return cumulative_f1_scores return cumulative_f1_scores