sedmetrics 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. sedmetrics-0.1.0/Cargo.lock +137 -0
  2. sedmetrics-0.1.0/Cargo.toml +14 -0
  3. sedmetrics-0.1.0/LICENSE-APACHE +202 -0
  4. sedmetrics-0.1.0/PKG-INFO +315 -0
  5. sedmetrics-0.1.0/README.md +285 -0
  6. sedmetrics-0.1.0/crates/sedmetrics-core/Cargo.toml +15 -0
  7. sedmetrics-0.1.0/crates/sedmetrics-core/LICENSE-APACHE +202 -0
  8. sedmetrics-0.1.0/crates/sedmetrics-core/README.md +285 -0
  9. sedmetrics-0.1.0/crates/sedmetrics-core/src/lib.rs +24 -0
  10. sedmetrics-0.1.0/crates/sedmetrics-core/src/matching.rs +170 -0
  11. sedmetrics-0.1.0/crates/sedmetrics-core/src/metrics/event.rs +324 -0
  12. sedmetrics-0.1.0/crates/sedmetrics-core/src/metrics/frame.rs +136 -0
  13. sedmetrics-0.1.0/crates/sedmetrics-core/src/metrics/mod.rs +8 -0
  14. sedmetrics-0.1.0/crates/sedmetrics-core/src/metrics/probability.rs +49 -0
  15. sedmetrics-0.1.0/crates/sedmetrics-core/src/metrics/psds.rs +777 -0
  16. sedmetrics-0.1.0/crates/sedmetrics-core/src/metrics/segment.rs +397 -0
  17. sedmetrics-0.1.0/crates/sedmetrics-core/src/metrics/streaming.rs +277 -0
  18. sedmetrics-0.1.0/crates/sedmetrics-core/src/types.rs +51 -0
  19. sedmetrics-0.1.0/crates/sedmetrics-core/src/validation.rs +286 -0
  20. sedmetrics-0.1.0/crates/sedmetrics-core/tests/event_f1.rs +460 -0
  21. sedmetrics-0.1.0/crates/sedmetrics-core/tests/frame.rs +26 -0
  22. sedmetrics-0.1.0/crates/sedmetrics-core/tests/probability.rs +10 -0
  23. sedmetrics-0.1.0/crates/sedmetrics-core/tests/psds.rs +264 -0
  24. sedmetrics-0.1.0/crates/sedmetrics-core/tests/segment_f1.rs +214 -0
  25. sedmetrics-0.1.0/crates/sedmetrics-core/tests/streaming.rs +62 -0
  26. sedmetrics-0.1.0/crates/sedmetrics-python/Cargo.toml +17 -0
  27. sedmetrics-0.1.0/crates/sedmetrics-python/src/lib.rs +1095 -0
  28. sedmetrics-0.1.0/pyproject.toml +57 -0
  29. sedmetrics-0.1.0/python/sedmetrics/__init__.py +44 -0
  30. sedmetrics-0.1.0/python/sedmetrics/__main__.py +8 -0
  31. sedmetrics-0.1.0/python/sedmetrics/_native.pyi +141 -0
  32. sedmetrics-0.1.0/python/sedmetrics/adapters.py +413 -0
  33. sedmetrics-0.1.0/python/sedmetrics/cli.py +103 -0
  34. sedmetrics-0.1.0/python/sedmetrics/dataset.py +247 -0
  35. sedmetrics-0.1.0/python/sedmetrics/evaluator.py +206 -0
  36. sedmetrics-0.1.0/python/sedmetrics/event.py +93 -0
  37. sedmetrics-0.1.0/python/sedmetrics/experimental/__init__.py +4 -0
  38. sedmetrics-0.1.0/python/sedmetrics/experimental/streaming.py +36 -0
  39. sedmetrics-0.1.0/python/sedmetrics/frame.py +115 -0
  40. sedmetrics-0.1.0/python/sedmetrics/psds.py +179 -0
  41. sedmetrics-0.1.0/python/sedmetrics/py.typed +0 -0
  42. sedmetrics-0.1.0/python/sedmetrics/report.py +208 -0
  43. sedmetrics-0.1.0/python/sedmetrics/segment.py +88 -0
@@ -0,0 +1,137 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "heck"
7
+ version = "0.5.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
10
+
11
+ [[package]]
12
+ name = "libc"
13
+ version = "0.2.191"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
16
+
17
+ [[package]]
18
+ name = "once_cell"
19
+ version = "1.21.4"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
22
+
23
+ [[package]]
24
+ name = "portable-atomic"
25
+ version = "1.15.0"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
28
+
29
+ [[package]]
30
+ name = "proc-macro2"
31
+ version = "1.0.107"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
34
+ dependencies = [
35
+ "unicode-ident",
36
+ ]
37
+
38
+ [[package]]
39
+ name = "pyo3"
40
+ version = "0.30.1"
41
+ source = "registry+https://github.com/rust-lang/crates.io-index"
42
+ checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
43
+ dependencies = [
44
+ "libc",
45
+ "once_cell",
46
+ "portable-atomic",
47
+ "pyo3-build-config",
48
+ "pyo3-ffi",
49
+ "pyo3-macros",
50
+ ]
51
+
52
+ [[package]]
53
+ name = "pyo3-build-config"
54
+ version = "0.30.1"
55
+ source = "registry+https://github.com/rust-lang/crates.io-index"
56
+ checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
57
+ dependencies = [
58
+ "target-lexicon",
59
+ ]
60
+
61
+ [[package]]
62
+ name = "pyo3-ffi"
63
+ version = "0.30.1"
64
+ source = "registry+https://github.com/rust-lang/crates.io-index"
65
+ checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
66
+ dependencies = [
67
+ "libc",
68
+ "pyo3-build-config",
69
+ ]
70
+
71
+ [[package]]
72
+ name = "pyo3-macros"
73
+ version = "0.30.1"
74
+ source = "registry+https://github.com/rust-lang/crates.io-index"
75
+ checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
76
+ dependencies = [
77
+ "proc-macro2",
78
+ "pyo3-macros-backend",
79
+ "quote",
80
+ "syn",
81
+ ]
82
+
83
+ [[package]]
84
+ name = "pyo3-macros-backend"
85
+ version = "0.30.1"
86
+ source = "registry+https://github.com/rust-lang/crates.io-index"
87
+ checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
88
+ dependencies = [
89
+ "heck",
90
+ "proc-macro2",
91
+ "quote",
92
+ "syn",
93
+ ]
94
+
95
+ [[package]]
96
+ name = "quote"
97
+ version = "1.0.47"
98
+ source = "registry+https://github.com/rust-lang/crates.io-index"
99
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
100
+ dependencies = [
101
+ "proc-macro2",
102
+ ]
103
+
104
+ [[package]]
105
+ name = "sedmetrics-core"
106
+ version = "0.1.0"
107
+
108
+ [[package]]
109
+ name = "sedmetrics-python"
110
+ version = "0.1.0"
111
+ dependencies = [
112
+ "pyo3",
113
+ "sedmetrics-core",
114
+ ]
115
+
116
+ [[package]]
117
+ name = "syn"
118
+ version = "3.0.10"
119
+ source = "registry+https://github.com/rust-lang/crates.io-index"
120
+ checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
121
+ dependencies = [
122
+ "proc-macro2",
123
+ "quote",
124
+ "unicode-ident",
125
+ ]
126
+
127
+ [[package]]
128
+ name = "target-lexicon"
129
+ version = "0.13.6"
130
+ source = "registry+https://github.com/rust-lang/crates.io-index"
131
+ checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
132
+
133
+ [[package]]
134
+ name = "unicode-ident"
135
+ version = "1.0.27"
136
+ source = "registry+https://github.com/rust-lang/crates.io-index"
137
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
@@ -0,0 +1,14 @@
1
+ [workspace]
2
+ resolver = "3"
3
+ members = ["crates/sedmetrics-core", "crates/sedmetrics-python"]
4
+
5
+ [workspace.package]
6
+ version = "0.1.0"
7
+ edition = "2024"
8
+ rust-version = "1.85"
9
+ license = "Apache-2.0"
10
+ repository = "https://github.com/LakoreAI/sed-metrics"
11
+
12
+ [profile.release]
13
+ lto = "thin"
14
+ codegen-units = 1
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,315 @@
1
+ Metadata-Version: 2.4
2
+ Name: sedmetrics
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Python :: 3 :: Only
7
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
8
+ Classifier: Topic :: Scientific/Engineering
9
+ Requires-Dist: pyarrow>=15 ; extra == 'data'
10
+ Requires-Dist: sed-eval==0.2.1 ; extra == 'parity'
11
+ Requires-Dist: setuptools<81 ; extra == 'parity'
12
+ Requires-Dist: sed-scores-eval==0.0.4 ; extra == 'parity'
13
+ Requires-Dist: numpy ; extra == 'parity'
14
+ Requires-Dist: pandas<3 ; extra == 'parity'
15
+ Requires-Dist: scikit-learn==1.9.1 ; extra == 'parity'
16
+ Requires-Dist: pytest>=8 ; extra == 'test'
17
+ Provides-Extra: data
18
+ Provides-Extra: parity
19
+ Provides-Extra: test
20
+ License-File: LICENSE-APACHE
21
+ Summary: Evaluation metrics for Sound Event Detection
22
+ Keywords: sound event detection,evaluation,metrics,audio,dcase
23
+ License-Expression: Apache-2.0
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
26
+ Project-URL: Homepage, https://github.com/LakoreAI/sed-metrics
27
+ Project-URL: Issues, https://github.com/LakoreAI/sed-metrics/issues
28
+ Project-URL: Repository, https://github.com/LakoreAI/sed-metrics
29
+
30
+ # SEDMetrics
31
+
32
+ Evaluation metrics for Sound Event Detection (SED), with a Rust computational
33
+ core and Python bindings through PyO3. SEDMetrics evaluates model outputs; it
34
+ does not train models, extract audio features or detect sound events itself.
35
+
36
+ The project has two goals: faithful, efficient implementations of established
37
+ evaluation protocols, and research on what conventional offline metrics cannot
38
+ measure, in particular the difference between estimated event boundaries and
39
+ the time at which a decision actually becomes available.
40
+
41
+ ## Status
42
+
43
+ This is an early bootstrap. The implemented and planned features are listed below.
44
+
45
+ | Area | Status |
46
+ | --- | --- |
47
+ | Collar-based event precision / recall / F1 (micro, macro, per class, with counts and mean localization error) | Implemented in Rust and Python |
48
+ | Segment-based precision / recall / F1 with S/D/I error rate | Implemented in Rust and Python |
49
+ | PSDS (intersection-based DTC/GTC/CTTC, PSDS1/PSDS2 profiles) | Implemented in Rust and Python |
50
+ | Dataset adapters: URBAN-SED v2.0.0 (dir or `.tar.gz`), AudioSet strong parquet | Implemented; `pyarrow` is optional and only needed for AudioSet |
51
+ | Reference parity | Tested for selected fixtures against `sed_eval` 0.2.1 (event, segment) and `sed_scores_eval` 0.0.4 (PSDS), including per-class PSDS curves |
52
+ | JSON evaluation report + `sedmetrics evaluate` CLI | Implemented |
53
+ | Frame precision/recall/F1, AP and AUROC | Implemented for aligned labels or event-to-frame mapping, with classwise, micro and macro results for event tracks |
54
+ | piPSDS | Implemented for explicitly supplied post-processed score tracks; reference parity tested on a fixture |
55
+ | Streaming / online metrics | Experimental CREATE-only fixed assignment, deadline recall, AUDR and false alerts per hour |
56
+ | Soft-label Brier score | Implemented for aligned single-class targets and probabilities |
57
+ | Diagnostics and post-processing | Not implemented |
58
+
59
+ Correctness caveats that apply right now:
60
+
61
+ - Selected event and segment fixtures are compared with `sed_eval` 0.2.1,
62
+ PSDS and piPSDS fixtures with `sed_scores_eval` 0.0.4, and frame and Brier
63
+ fixtures with scikit-learn. There is no parity evidence for `psds_eval`.
64
+ - Parity runs use synthetic predictions derived from references, on sampled
65
+ URBAN-SED test clips and AudioSet strong clips. They are not a benchmark of
66
+ any system.
67
+ - `sedmetrics evaluate` reads predictions from a TSV/CSV table and reports
68
+ event/segment metrics; PSDS needs score tracks and is available through the
69
+ Python API only. DCASE score files and model checkpoints are not read. The
70
+ experimental streaming API evaluates complete CREATE alert logs.
71
+
72
+ ## Install
73
+
74
+ ```bash
75
+ python -m pip install sedmetrics
76
+ ```
77
+
78
+ If a compatible wheel is unavailable, installing the source distribution
79
+ requires a Rust compiler. The Rust library is available as `sedmetrics-core`.
80
+
81
+ ## Install from source
82
+
83
+ Requires Rust 1.85+ and Python 3.10+.
84
+
85
+ ```bash
86
+ python -m venv .venv && source .venv/bin/activate
87
+ pip install maturin
88
+ maturin develop --release
89
+ pip install "sedmetrics[data]" # optional: pyarrow, for AudioSet parquet
90
+ ```
91
+
92
+ ## Usage
93
+
94
+ For a single metric, use the simple entry point:
95
+
96
+ ```python
97
+ from sedmetrics import SEDMetrics
98
+
99
+ result = SEDMetrics.eval(
100
+ references=[(0, 0, 0.0, 1.0)],
101
+ predictions=[(0, 0, 0.05, 1.0)],
102
+ )
103
+ print(result.f1, result.n_correct)
104
+ ```
105
+
106
+ The default is collar-based event F1. Pass `metric="segment_f1"` and
107
+ `recordings={0: 2.0}` for segment metrics, or `metric="psds"`, `scores=...`
108
+ and `recordings=...` for PSDS. Metric-specific options can be passed as keyword
109
+ arguments. A `Dataset` can be passed as `references` to use names and its
110
+ recording durations. The lower-level APIs remain available:
111
+
112
+ ```python
113
+ results = SEDMetrics.eval(
114
+ references=[(0, 0, 0.0, 1.0)],
115
+ predictions=[(0, 0, 0.05, 1.0)],
116
+ recordings={0: 2.0},
117
+ metrics=["event_f1", "segment_f1"],
118
+ metric_options={"event_f1": {"onset_collar": 0.1}},
119
+ )
120
+ print(results["event_f1"].f1, results["segment_f1"].f1)
121
+ ```
122
+
123
+ `metrics` always returns a dictionary, even with one selection. The singular
124
+ `metric` argument returns a single result. When combining event metrics with
125
+ PSDS, supply both `predictions` and complete `scores`.
126
+
127
+ ```python
128
+ import sedmetrics as sm
129
+
130
+ result = sm.event.f1(
131
+ references=[(0, 0, 0.0, 1.0), (0, 0, 2.0, 3.0), (0, 0, 4.0, 5.0)],
132
+ predictions=[(0, 0, 0.0, 1.0), (0, 0, 2.0, 3.0), (0, 0, 7.0, 8.0)],
133
+ onset_collar=0.2,
134
+ offset_collar=0.2,
135
+ offset_ratio=0.2,
136
+ average="micro",
137
+ )
138
+
139
+ print(result.f1, result.precision, result.recall)
140
+ print(result.n_correct, result.n_insertions, result.n_deletions)
141
+ print(result.to_dict())
142
+ ```
143
+
144
+ Each event is `(recording_id, class_id, onset, offset)` in seconds, a mapping
145
+ with those keys, or an object exposing them as attributes. Intervals are
146
+ half-open, `[onset, offset)`. Undefined ratios are `None`, never `NaN`.
147
+
148
+ Evaluating on a dataset, using class and recording names instead of ids:
149
+
150
+ ```python
151
+ dataset = sm.adapters.load_urban_sed("data/raw/URBAN-SED_v2.0.0.tar.gz", split="test")
152
+
153
+ result = dataset.event_f1(
154
+ [("soundscape_test_1", "siren", 1.05, 2.45)],
155
+ average="macro",
156
+ )
157
+ ```
158
+
159
+ See `docs/adapters.md` for dataset layouts, id assignment and duration rules.
160
+
161
+ Segment-based metrics and a reproducible JSON report:
162
+
163
+ ```python
164
+ dataset = sm.adapters.load_urban_sed("data/raw/URBAN-SED_v2.0.0.tar.gz", split="test")
165
+
166
+ print(dataset.segment_f1(predictions, segment_length=1.0).error_rate)
167
+
168
+ report = sm.report.evaluate(dataset, predictions, metrics=["event_f1", "segment_f1"])
169
+ sm.report.write_report(report, "results/run.json")
170
+
171
+ # or from the command line, with predictions in a TSV/CSV table
172
+ # sedmetrics evaluate --dataset urban-sed --root data/raw --predictions preds.tsv --out results/run.json
173
+ ```
174
+
175
+ PSDS from per-frame scores:
176
+
177
+ ```python
178
+ result = SEDMetrics.eval(
179
+ references=[(0, 0, 1.0, 2.0)],
180
+ metric="psds",
181
+ recordings={0: 3.0},
182
+ scores={0: ([0.0, 1.0, 2.0, 3.0], {0: [0.1, 0.9, 0.1]})},
183
+ )
184
+ print(result.psds, result.classes[0].tpr)
185
+ ```
186
+
187
+ Supply a complete track for every recording and every evaluated class; its
188
+ boundaries must span the recording's full duration.
189
+
190
+ DCASE PSDS1 is the default configuration; PSDS2 means
191
+ `dtc_threshold=0.1, gtc_threshold=0.1, cttc_threshold=0.3, alpha_ct=0.5`.
192
+ `alpha_st` defaults to 1.0 here, unlike `sed_scores_eval` (0.0).
193
+
194
+ For explicitly aligned binary frame labels and scores, use:
195
+
196
+ ```python
197
+ result = SEDMetrics.eval(
198
+ references=[True, False, True], scores=[0.9, 0.8, 0.1],
199
+ mode="frame", threshold=0.5,
200
+ boundaries=[0.0, 0.2, 0.5, 1.0], weighting="duration",
201
+ )
202
+ print(result["f1"], result["average_precision"], result["auroc"])
203
+ ```
204
+
205
+ The example uses pre-aligned labels for one class; see
206
+ `docs/metrics/frame_binary.md` for the contract.
207
+ Pass `metrics=["f1", "auroc"]` to select frame metrics; counts and configuration
208
+ are always included.
209
+
210
+ To map events to score frames and compute classwise, micro and macro metrics:
211
+
212
+ ```python
213
+ result = SEDMetrics.eval(
214
+ references=[(0, 0, 0.9, 1.0)], mode="frame", recordings={0: 2.0},
215
+ scores={0: ([0.0, 1.0, 2.0], {0: [0.8, 0.2], 1: [0.1, 0.7]})},
216
+ threshold=0.5,
217
+ )
218
+ print(result["micro"]["f1"], result["classes"][0]["f1"])
219
+ ```
220
+
221
+ A frame is positive when it has any positive-duration overlap with a reference
222
+ of the same class; see `docs/metrics/frame_events.md` for the full contract.
223
+ For aligned soft targets and probabilities, use
224
+ `SEDMetrics.eval([0.2, 0.8], mode="probability", scores=[0.2, 0.5])` to
225
+ compute Brier score; its interpretation is in `docs/metrics/brier.md`.
226
+
227
+ For piPSDS, pass `metric="pipsds"` and a mapping from processing names to
228
+ complete score-track mappings via `scores`. The envelope can choose a different
229
+ processing at different operating points and is not a single deployed policy;
230
+ see `docs/metrics/pipsds.md`.
231
+
232
+ The experimental streaming baseline accepts immutable CREATE alerts with
233
+ explicit decision and audio availability times:
234
+
235
+ ```python
236
+ result = SEDMetrics.eval(
237
+ references=[(0, 0, 0.0, 0.5)], mode="streaming", recordings={0: 10.0},
238
+ alerts=[(0, 1, 0, 0.1, 0.1, 0.1)],
239
+ class_ids=[0], matching_window=1.0, deadlines=[0.25, 0.5], horizon=1.0, clock="simulated",
240
+ )
241
+ print(result["deadline_recall"], result["audr"], result["false_alerts_per_hour"])
242
+ ```
243
+
244
+ The tuple is recording ID, alert ID, class ID, emitted time, audio available
245
+ until, and latest audio used (or `None`). The current protocol requires complete
246
+ recording observation, scores CREATE actions only, and treats references near
247
+ the end as censored. See `docs/streaming-protocol.md` for the matching policy,
248
+ clock assumptions, and limitations.
249
+
250
+ ## Development
251
+
252
+ ```bash
253
+ cargo fmt --all -- --check
254
+ cargo clippy -p sedmetrics-core --all-targets -- -D warnings
255
+ cargo test -p sedmetrics-core # pure Rust, no Python needed
256
+ maturin develop --release
257
+ python -m pytest # unit, integration, parity
258
+
259
+ pip install "sedmetrics[parity]" # sed_eval 0.2.1 oracle for parity tests
260
+ SEDMETRICS_RAW_DATA=/path/to/data/raw python -m pytest tests/parity
261
+ ```
262
+
263
+ The PSDS parity suite needs `sed_scores_eval`, a working SciPy, and
264
+ `pandas < 3`. If the dependencies do not load in your development environment,
265
+ run the oracle from a separate Python 3.12 environment:
266
+
267
+ ```bash
268
+ uv venv --python 3.12 .venv-oracle
269
+ uv pip install --python .venv-oracle/bin/python pytest pyarrow "sedmetrics[parity]" \
270
+ --find-links dist
271
+ maturin build --release -o dist && uv pip install --python .venv-oracle/bin/python \
272
+ --force-reinstall dist/*.whl
273
+ .venv-oracle/bin/python -m pytest tests/parity
274
+ ```
275
+
276
+ `sedmetrics-python` is built with the `pyo3/extension-module` feature by
277
+ maturin, so Rust-level checks target `sedmetrics-core`; the binding itself is
278
+ covered by the Python tests.
279
+
280
+ ## Documentation
281
+
282
+ - `docs/metrics/event_f1.md`: specification of the implemented metric
283
+ (definition, matching policy, aggregation, undefined values, defaults,
284
+ hand-computed example, parity evidence, limitations).
285
+ - `docs/metrics/segment_f1.md`: segment-based metric and S/D/I decomposition.
286
+ - `docs/metrics/psds.md`: PSDS definition, criteria, profiles and parity.
287
+ - `docs/adapters.md`: dataset formats, id assignment, duration rules.
288
+ - `docs/streaming-protocol.md`: experimental streaming evaluation contract and censoring policy.
289
+ - `docs/decisions/0001-baseline.md`: license, platforms, CI and metric order.
290
+
291
+ ## Supported platforms
292
+
293
+ | Tier | Platforms | Status |
294
+ | --- | --- | --- |
295
+ | 1 | macOS arm64, Linux x86_64 | Built and tested |
296
+ | 2 | Linux aarch64, Windows x86_64 | Expected to build, untested |
297
+ | — | 32-bit targets, musl wheels | Not supported |
298
+
299
+ CPython 3.10-3.13 via the `abi3-py310` stable ABI, so one wheel per platform
300
+ works across those versions. Rust 1.85+ is required to build from source.
301
+
302
+ CI (`.github/workflows/ci.yml`) runs the Rust checks, the Python suite on Linux
303
+ and macOS, and the reference-parity suite on Linux. See GitHub Actions for the
304
+ status of the latest run.
305
+
306
+ ## License
307
+
308
+ Licensed under the Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE)).
309
+ Unless you explicitly state otherwise, any contribution intentionally submitted
310
+ for inclusion in this project shall be licensed under the same terms, without
311
+ additional conditions.
312
+
313
+ The reference oracles used in tests (`sed_eval`, `sed_scores_eval`) are
314
+ development-only dependencies and are not distributed with this project.
315
+