-
Notifications
You must be signed in to change notification settings - Fork 156
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
[MNT, ENH, DOC] Rework similarity search #2473
base: main
Are you sure you want to change the base?
Conversation
Thank you for contributing to
|
Thank you very much for working on this. Some thoughts:
That is an interesting problem. Here is my view: For whole series similarity search fit requires a dataset of time series of equal length, and find_neighbors would get one or many query series of this length. For subsequence similarity search fit requires a single time series, and find_neighbors commonly gets a single query sequence which length is shorter than the single series length. It would be fine however, to extend it to multiple short sequences. There is only one whole series consensus motif search paper, which would be the use case of whole matching and motif discovery. The input to fit would be the whole dataset, and find_motif has no input series X. not sure, what an input series X should trigger. Most papers solve the problem of motif discovery in a single long time series, defined as subsequences of the time series. Here, fit gets a single series, and find_motif has no input series X.
What is the difference between BaseMatrixProfile and STOMP? At least for Motiflets, we cannot use STOMP/MP, as it only gives a 1-NN profile, but we need k-NN profiles. Same problem would be the case, if you want to solve k-nearest neighbors similarity search.
I think that X is not meaningful for motif discovery. |
Thanks for the inputs @patrickzib😄
Completely in line with this, but what about the case of unequal length series, with, for example, elastic distance measures? Wouldn't that be a plausible use case? (all whole series estimators don't have to support it)
For this case, I'm defining a length parameter during
This is the tricky one for me too. I'm not sure how giving
I've been kinda frustrated by this limitation for practical use cases, wouldn't it be fine to loop on series of a collection with the motif discovery methods and then merge the results ? That's how I implemented STOMP for now for example. For each subsequence in
As stated above, I already extended STOMP to support k-NN profiles for collections (multivariate and unequal length compatible). I suppose that in this context, motiflets would either inherit from Note that it's possible to simply raise a "NotImplementedError" or something similar if an estimator would only support neighbors or motifs search. My goal here is to find a base class structure that enables us to move most common code to there and focus on the computational optimisations of each method in the child classes.
In the context of motif search in a single series I agree, but wouldn't there be some interest when dealing with a collection ? For example find motifs in the collection at the condition that they are similar to a subsequence in X ? (This is pure speculation) |
Sure. I did not think of this.
Simplicity :) But I agree that you could have multiple series in fit, too - this would mimic the Shapelet use case, I suppose?
Sorry, yes, that is what the authors refer to as consensus motif:
I see. I personally do not like to use the terms matrix-profile for simple k-NN distances or k-NN indices though. It was a brilliant re-framing of EK, such that all 1-NN algorithms are now suddenly an instance of matrix profile. Yet, the concept is much older.
Great.
I would not say that this is impossible, but I have not seen it. :) |
I'm not 100% sure what you mean, but in a sense yes ? For example with a brute force neighbour search, just compute the distance of the subsequence given in
I'm not against the idea of a different naming, especially if methods labelled differently from MPs would fit in the base class without much change of parameter/interface. Would you have any proposal? Something like |
In sklearn it is simply |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
…class-with-attimo-algorithm
I'll leave the implementation of |
Reference Issues/PRs
Fixes #2341, #2236, #2028, #2020, #1806, #2475
What does this implement/fix? Explain your changes.
The previous structure for similarity search was not in line with the structure we would expect considering other aeon modules, the lack of distinct base classes for some tasks, as well as the initial design choice (due to the lack of practical experience with using and expanding the module) lead to some really complex code when working on #2341 to make everything work together. Further expanding the module would have made thing worse.
To make the module more flexible and comprehensible, the following rework is proposed in this PR (AEP to be updated acordingly):
The module structure is now :
Base classes are
BaseSimilaritySearch, BaseSeriesSimilaritySearch, BaseCollectionSimilaritySearch
Implemented estimators are :
The sufix of the estimators (SNN/ANN/Motifs) remains an open discussion, not sure it's the right way to go.
I removed the support for collections for Stomp and Mass for now to focus on the "expected and well known" use cases, I'll make them in another PR.
All similarity search estimators now use fit/predict interface, with predict returning two arrays (NN/Motifs indexes, and NN/Motifs distances).
Does your contribution introduce a new dependency? If yes, which one?
No.
Any other comments?
As this is still a WIP, I would love some inputs on the structure (notably from @patrickzib !) to make the module more future-proof to future additions and easier to use.
TODO list :
SubsequenceSearch
part and fix themBaseCollectionSimilaritySearch