-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] Added IDK² and s-IDK² Anomaly Detector To Aeon #2465
base: main
Are you sure you want to change the base?
Conversation
Thank you for contributing to
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just had a very brief look at the code because I am short on time. I will have another look next year after the Christmas break. Meanwhile, the code quality can be improved and tests need to be added.
- The tests are missing! Please add reasonable tests for the new algorithm. How do you make sure that it produces the same results as the original implementation?
- The code mixes standard python (e.g.
random
,range
, ...) with numpy (e.g.np.random
,np.arange
, ...). Please mostly rely on numpy for better code quality and performance. - Why are most methods in capital letters and start with dunders (
__
)? If this is a reference to the original implementation, please add the original name as a comment and use our coding standard.
Thank you for taking the time and contributing to aeon!
Hello, I recently added a test case, but it seems to be causing errors. The test case runs successfully in my local environment, so I'm unsure why the issue arises. Could you assist me in identifying the cause? |
from aeon.anomaly_detection import IDK | ||
|
||
|
||
def test_idk_univariate(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to make sure that our implementation is correct. Can you add tests that compare your implementation to the original authors' one?
You already linked to the reference implementation: https://github.com/IsolationKernel/Codes/tree/main/IDK/TS
You can execute the reference implementation on some sample data and store the results. Then, you could test this implementation on the same input data to produce the same results up to a certain precision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added new case for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the test case in a new function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
assert pred.shape == (100,) | ||
assert pred.dtype == np.float64 | ||
assert 50 <= np.argmax(pred) <= 58 | ||
assert pred_sliding.shape == (91,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result should have the same shape as the input in both cases!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The width parameter changes the way the model generates its output, since its 10 the output length 91(91 windows - each size of 10)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I get that, but there must be a way to calculate, which points of the original time series contributed to the score at a certain position. All existing aeon anomaly detectors adhere to this contract.
In the other ADs of this module that use sliding windows, we use aeon.utils.windowing.reverse_windowing
to attribute the anomaly score to the original points of the time series. For IDK, I guess this does not work, but maybe for IDK². We need to figure out a way to do this for IDK and IDK² even if it is not part of the original code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I utilized the aeon.utils.windowing.reverse_windowing function to ensure the output shape aligns with the input shape when sliding is enabled. Could you please review it to confirm that my implementation is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The testing is still too weak.
TBH, I cannot follow the details of the code, so I think that we need a second person to check whether this implementation produces the same results as the implementation by the original authors of IDK.
assert pred.shape == (100,) | ||
assert pred.dtype == np.float64 | ||
assert 50 <= np.argmax(pred) <= 58 | ||
assert pred_sliding.shape == (91,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I get that, but there must be a way to calculate, which points of the original time series contributed to the score at a certain position. All existing aeon anomaly detectors adhere to this contract.
In the other ADs of this module that use sliding windows, we use aeon.utils.windowing.reverse_windowing
to attribute the anomaly score to the original points of the time series. For IDK, I guess this does not work, but maybe for IDK². We need to figure out a way to do this for IDK and IDK² even if it is not part of the original code.
from aeon.anomaly_detection import IDK | ||
|
||
|
||
def test_idk_univariate(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the test case in a new function.
closes #2114