[ENH] Fix inverted label mapping in OutlierDetectionAdapter & add adapter tests#3209
[ENH] Fix inverted label mapping in OutlierDetectionAdapter & add adapter tests#3209Adityakushwaha2006 wants to merge 14 commits intoaeon-toolkit:mainfrom
Conversation
… creation for adapters.
Thank you for contributing to
|
aeon/anomaly_detection/collection/tests/test_outlier_detection.py
Outdated
Show resolved
Hide resolved
aeon/anomaly_detection/collection/tests/test_outlier_detection.py
Outdated
Show resolved
Hide resolved
…sts with IsolationForest & RandomForestClassifier
1cdc6fa to
f9aa284
Compare
SebastianSchmidl
left a comment
There was a problem hiding this comment.
Nice work 👍🏼
Just some minor documentation improvements
aeon/anomaly_detection/collection/tests/test_outlier_detection.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Sebastian Schmidl <10573700+SebastianSchmidl@users.noreply.github.com>
Co-authored-by: Sebastian Schmidl <10573700+SebastianSchmidl@users.noreply.github.com>
SebastianSchmidl
left a comment
There was a problem hiding this comment.
LGTM, but let's wait until @MatthewMiddlehurst had a chance to look at this as well. I'm not super sure that we do not already have some dummy fixtures for the tests.
MatthewMiddlehurst
left a comment
There was a problem hiding this comment.
Good catch on the output, got the labels backwards!
If you go into the testing module we have some pre-made testing data which can be used here instead of creating it when we don't need to. This is pretty minor though, so can merge without it if no change is made.
aeon/anomaly_detection/collection/tests/test_outlier_detection.py
Outdated
Show resolved
Hide resolved
aeon/anomaly_detection/collection/tests/test_outlier_detection.py
Outdated
Show resolved
Hide resolved
637a596 to
2f1d9a9
Compare
Co-authored-by: Sebastian Schmidl <10573700+SebastianSchmidl@users.noreply.github.com>
|
currently failing tests |
Reference Issues/PRs
Fixes #3184
Addresses the request for targeted test coverage for collection anomaly detection adapters.
Fixes a logic error discovered in
OutlierDetectionAdapter.What does this implement/fix? Explain your changes.
This PR adds unit tests for
ClassificationAdapterandOutlierDetectionAdapteras requested and fixes a critical logic bug in the outlier adapter.1. Bug Fix in
OutlierDetectionAdapter-1) to0(Normal) and inliers (1) to1(Anomaly)._predictinaeon/anomaly_detection/collection/_outlier_detection.pyto correctly map-1to1(Anomaly).pred[pred == -1] = 0(Incorrect)return (pred == -1).astype(int)(Correct: Outlier becomes Anomaly/True)2. Added Targeted Tests
Added two new test files focusing exclusively on the adapter "translation" logic (avoiding generic shape/crash tests covered by
check_estimator):aeon/anomaly_detection/collection/tests/test_outlier_detection.py: Verifies that Sklearn labels (-1,1) are correctly translated to Aeon standards (1,0). Includes a safety test to ensure no raw-1values leak into the output.aeon/anomaly_detection/collection/tests/test_classification.py: Verifies that theClassificationAdapteracts as a transparent passthrough for binary labels.Does your contribution introduce a new dependency? If yes, which one?
No.
Any other comments?
The tests use
DummyClassifierandDummyOutlierDetectormocks to ensure they are fast, deterministic, and do not require training real models.PR checklist
For all contributions
For new estimators and functions
__maintainer__at the top of relevant files and want to be contacted regarding its maintenance. Unmaintained files may be removed. This is for the full file, and you should not add yourself if you are just making minor changes or do not want to help maintain its contents.For developers with write access