Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autosimilarity_segmentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MARMORET Axel
autosimilarity_segmentation
Commits
337d5596
Commit
337d5596
authored
9 months ago
by
MARMORET Axel
Browse files
Options
Downloads
Patches
Plain Diff
Adding the trimming option as a parameter in the score computation function.
parent
47a5005c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
as_seg/data_manipulation.py
+8
-3
8 additions, 3 deletions
as_seg/data_manipulation.py
with
8 additions
and
3 deletions
as_seg/data_manipulation.py
+
8
−
3
View file @
337d5596
...
...
@@ -555,7 +555,7 @@ def compute_score_from_frontiers_in_bar(reference, frontiers_in_bar, bars, windo
frontiers_in_time
=
frontiers_from_bar_to_time
(
frontiers_in_bar
,
bars
)
return
compute_score_of_segmentation
(
reference
,
frontiers_to_segments
(
frontiers_in_time
),
window_length
=
window_length
)
def
compute_score_of_segmentation
(
reference
,
segments_in_time
,
window_length
=
0.5
):
def
compute_score_of_segmentation
(
reference
,
segments_in_time
,
window_length
=
0.5
,
trim
=
False
):
"""
Computes precision, recall and f measure from estimated segments and the reference, both in seconds.
Scores are computed from the mir_eval toolbox.
...
...
@@ -569,6 +569,11 @@ def compute_score_of_segmentation(reference, segments_in_time, window_length = 0
window_length : float, optional
The window size for the score (tolerance for the frontier to be validated).
The default is 0.5.
trim : boolean, optional
Whether (True) or not (False) the first and last boundaries should be
"
trimmed
"
,
i.e. discarded in the computation of accurate boundaries.
Default is False, meaning that they are kept by default.
This may artifically increase the metrics, but is the standard in the benchmarks.
Returns
-------
...
...
@@ -586,14 +591,14 @@ def compute_score_of_segmentation(reference, segments_in_time, window_length = 0
ref_intervals
,
useless
=
mir_eval
.
util
.
adjust_intervals
(
reference
,
t_min
=
0
)
est_intervals
,
useless
=
mir_eval
.
util
.
adjust_intervals
(
np
.
array
(
segments_in_time
),
t_min
=
0
,
t_max
=
ref_intervals
[
-
1
,
1
])
try
:
return
mir_eval
.
segment
.
detection
(
ref_intervals
,
est_intervals
,
window
=
window_length
,
trim
=
True
)
return
mir_eval
.
segment
.
detection
(
ref_intervals
,
est_intervals
,
window
=
window_length
,
trim
=
trim
)
except
ValueError
:
cleaned_intervals
=
[]
#print("A segment is (probably) composed of the same start and end. Can happen with time -> bar -> time conversion, but should'nt happen for data originally segmented in bars.")
for
idx
in
range
(
len
(
est_intervals
)):
if
est_intervals
[
idx
][
0
]
!=
est_intervals
[
idx
][
1
]:
cleaned_intervals
.
append
(
est_intervals
[
idx
])
return
mir_eval
.
segment
.
detection
(
ref_intervals
,
np
.
array
(
cleaned_intervals
),
window
=
window_length
,
trim
=
True
)
return
mir_eval
.
segment
.
detection
(
ref_intervals
,
np
.
array
(
cleaned_intervals
),
window
=
window_length
,
trim
=
trim
)
def
compute_median_deviation_of_segmentation
(
reference
,
segments_in_time
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment