Skip to content

Commit

Permalink
Fix f1 score calculation (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryukinix authored Nov 12, 2023
1 parent 7f9f6eb commit fedf645
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion egsis/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def iou(y_true: np.ndarray, y_pred: np.ndarray) -> float:
def f1(y_true: np.ndarray, y_pred: np.ndarray) -> float:
_check_if_they_are_binarized(y_true, y_pred)
intersection = y_true & y_pred
total_size = y_true.size + y_pred.size
total_size = y_true.sum() + y_pred.sum()
return (2 * intersection.sum()) / total_size


Expand Down
2 changes: 1 addition & 1 deletion tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_iou(x, y):


def test_f1(x, y):
assert metrics.f1(x, y) == pytest.approx(0.11111, 0.001)
assert metrics.f1(x, y) == pytest.approx(0.33333, 0.001)


def test_iou_raise_error_on_non_binarized_labels(x, y):
Expand Down

0 comments on commit fedf645

Please sign in to comment.