-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: made sure sound event evaluation works with nips example
- Loading branch information
1 parent
1f76da4
commit a1ca192
Showing
7 changed files
with
79 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,42 @@ | ||
"""Test suite for sound event detection evaluation.""" | ||
from pathlib import Path | ||
|
||
from soundevent import data, io | ||
from soundevent.evaluation import sound_event_detection | ||
|
||
TEST_DATA = Path(__file__).parent.parent / "data" | ||
|
||
|
||
def test_can_evaluate_nips_data(): | ||
"""Test that we can evaluate the NIPS data.""" | ||
evaluation_set = io.load( | ||
TEST_DATA / "nips4b_evaluation_set.json", | ||
type="evaluation_set", | ||
) | ||
model_run = io.load( | ||
TEST_DATA / "nips4b_model_run.json", | ||
type="model_run", | ||
) | ||
|
||
evaluation = sound_event_detection( | ||
model_run.clip_predictions, | ||
evaluation_set.clip_annotations, | ||
tags=evaluation_set.evaluation_tags, | ||
) | ||
|
||
assert isinstance(evaluation, data.Evaluation) | ||
|
||
# check that all clips have been evaluated | ||
assert len(evaluation.clip_evaluations) == len( | ||
evaluation_set.clip_annotations | ||
) | ||
|
||
# check that all metrics are present | ||
assert len(evaluation.metrics) == 4 | ||
metric_names = {metric.name for metric in evaluation.metrics} | ||
assert metric_names == { | ||
"balanced_accuracy", | ||
"accuracy", | ||
"top_3_accuracy", | ||
"mean_average_precision", | ||
} |