-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow evaluating predictions with only background (#23)
In the previous implementation, having no lesion candidates broke the evaluation. Added tests for having zero or one lesion candidate.
- Loading branch information
1 parent
e499134
commit cc134eb
Showing
4 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ def run(self): | |
long_description = fh.read() | ||
|
||
setuptools.setup( | ||
version='1.4.9', # also update version in metrics.py -> version | ||
version='1.4.10', # also update version in metrics.py -> version | ||
author_email='[email protected]', | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import numpy as np | ||
|
||
from picai_eval import Metrics | ||
|
||
|
||
def test_calculate_counts(): | ||
""" | ||
Test the lesion TPR and FPR function | ||
""" | ||
lesion_results = { | ||
"0": [(0, 0, 0.)], | ||
"1": [(0, 0, 0.)], | ||
"2": [(1, 1, 0.)], | ||
"3": [(1, 0, 0.), (1, 0, 0.)], | ||
"4": [(0, 0, 0.)], | ||
"5": [(1, 0, 0.), (1, 0, 0.)], | ||
} | ||
metrics = Metrics(lesion_results=lesion_results) | ||
np.testing.assert_allclose(metrics.lesion_TPR, [0.2, 0.2]) | ||
np.testing.assert_allclose(metrics.lesion_FPR, [0.0, np.inf]) | ||
assert metrics.AP == 0.2 | ||
|
||
|
||
def test_calculate_counts_empty(): | ||
""" | ||
Test the lesion TPR and FPR function | ||
""" | ||
lesion_results = { | ||
"0": [(0, 0, 0.)], | ||
"1": [(0, 0, 0.)], | ||
"2": [(1, 0, 0.)], | ||
"3": [(1, 0, 0.), (1, 0, 0.)], | ||
"4": [(0, 0, 0.)], | ||
"5": [(1, 0, 0.), (1, 0, 0.)], | ||
} | ||
metrics = Metrics(lesion_results=lesion_results) | ||
np.testing.assert_allclose(metrics.lesion_TPR, [0., 0.0]) | ||
np.testing.assert_allclose(metrics.lesion_FPR, [0.0, np.inf]) | ||
assert metrics.AP == 0.0 | ||
|
||
|
||
if __name__ == "__main__": | ||
test_calculate_counts() | ||
test_calculate_counts_empty() |