truelearn.utils.metrics
.get_f1_score#
- truelearn.utils.metrics.get_f1_score(act_labels: Iterable[bool], pred_labels: Iterable[bool], zero_division: Optional[int] = None) float [source]#
Get the f1 score of the prediction.
The formula for the F1 score is:
F1 = 2 * (precision * recall) / (precision + recall)
The highest possible value of an F-score is 1.0, indicating perfect precision and recall, and the lowest possible value is 0, if either precision or recall are zero.
- Parameters:
act_labels – An iterable of actual labels
pred_labels – An iterable of predicted labels
zero_division – Sets the value to return when there is a zero division. Defaults to None, which sets the value to zero and raises a warning. Acceptable values are 0 or 1, which sets the resulting value according.
- Returns:
The f1 score.