aeon
aeon copied to clipboard
[ENH]Use n_jobs parameter in KNeighborsTimeSeriesClassifier.
Reference Issues/PRs
Fixes #2478. See also #2545 and #2578.
What does this implement/fix? Explain your changes.
Uses n_jobs parameter in _predict and predict_proba of KNeighborsTimeSeriesClassifier. Parallelization is done in these methods instead of _kneighbors to potentially allow speedup through upper bounding the distance.
PR checklist
For all contributions
- [x] I've added myself to the list of contributors. Alternatively, you can use the @all-contributors bot to do this for you after the PR has been merged.
- [x] The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF], [DEP] or [GOV] indicating whether the PR topic is related to enhancement, maintenance, documentation, bugs, refactoring, deprecation or governance.
Thank you for contributing to aeon
I have added the following labels to this PR based on the title: [ $\color{#FEF1BE}{\textsf{enhancement}}$ ]. I have added the following labels to this PR based on the changes made: [ $\color{#BCAE15}{\textsf{classification}}$ ]. Feel free to change these if they do not properly represent the PR.
The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.
If our pre-commit code quality check fails, any trivial fixes will automatically be pushed to your PR unless it is a draft.
Don't hesitate to ask questions on the aeon Slack channel if you have any.
PR CI actions
These checkboxes will add labels to enable/disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.
- [ ] Run
pre-commitchecks for all files - [ ] Run
mypytypecheck tests - [ ] Run all
pytesttests and configurations - [ ] Run all notebook example tests
- [ ] Run numba-disabled
codecovtests - [ ] Stop automatic
pre-commitfixes (always disabled for drafts) - [ ] Disable numba cache loading
- [ ] Push an empty commit to re-run CI checks
In #2478, I've put some benchmarks. These are the entries on three data sets with 1 or 8 cores with only Aeon's builtin DTW:
| name | avg | std | min |
|---|---|---|---|
| ACSF1 (1) | 110.2201 | 2.4291 | 107.7615 |
| ACSF1 (8) | 49.2053 | 1.0859 | 48.3538 |
| ArrowHead (1) | 1.8508 | 0.0506 | 1.7939 |
| ArrowHead (8) | 0.5634 | 0.0114 | 0.5545 |
| GunPoint (1) | 0.8112 | 0.0238 | 0.7918 |
| GunPoint (8) | 1.0206 | 1.6650 | 0.2700 |
For the small GunPoint data set, overhead is larger than gains from parallelization. I expect that for ED, data sets would need to be larger to get a performance increase (if that's even possible) compared to DTW.
Equivalence is tested in aeon/distances/tests/test_sklearn_compatibility.py: previous version tested equivalence with sklearn. The test passes with the new version, so the new output is equal to the old output.
LGTM. Question is still open on whether this is the best way to do this for KNN, but it is much better than nothing.