refactored and optimized segmentation metrics eval #395
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactored and optimized segmentation metrics evaluation.
Refactoring:
key purpose is to make some of the methods more useful for extension in client libraries, make code more concise, reducing code duplications, thus also increasing possible community support
Optimisation:
here we note, that some code duplications lead us to recalculate some preparative steps for metric calculation. Reusing common logical steps helped to significantly increase performance. In our microbenchmark of
segment.eval()
we have achieved 1.58 speedup!This may be crucial in some applications that may require intensive metric calculation (like Hyperparameter Optimization)
Benchmarking details:
We took some symbolic music files (midis) with known expert markup of musical segments. There were 20 data points considered. We ran 300 iterations of eval method over all data provided to get better averaging.
Benchmarking results:
Before: time: 24.702 and latency: 0.0823, avg per data point: 0.0041
After: time: 15.615 and latency: 0.0520, avg per data point: 0.0026
Speedup is: 1.582 (~ -37%)