[MNT] Similarity search cleanup#3222
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Thank you for contributing to
|
…nterface Also corrects MASS capability:multithreading tag to False (it has no threading machinery), which unblocks check_multithreading_param. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… clarify whole_series base Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…timator Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…h BruteForce class Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…otebooks Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e, debug and optimize top k and mask, re-use distance module functions, harden input validation.
|
CI Error unrelated to the changes |
…k params to be fairer comparison
|
just wondering whether k could be used in fit to avoid calculations? |
|
forgive my ignorance, but the obvious use case for me is searching for a subseries in a single long series? I guess that just collapses to passing (1,n_channels, n_timepoints)? |
|
agsain, just general thoughts on a first look through, but could we generalise this to any aeon distance function? At least for the naive exact searchers? |
|
For the naive search sure, i can pass a distance arg that fetch distance modules funcs. |
|
Regarding k in fit, I ́m not sure I understand what you had in mind, you can’t precompute distances without a query. Or are you talking about approximate methods ? |
I think I was just wrong :) |
TonyBagnall
left a comment
There was a problem hiding this comment.
I like it, I think this is an improvement. Like the coverage too :) Im happy to approve it. Chatgpt had some niggles when I got it to read, only one I think maybe should go in is this
SimHashIndexANNshould validate integer hyperparameters more strictly.
At the moment n_tables and n_bits_per_table appear to be checked by value comparisons, but not by type. That means floats and bools can pass the early validation and then fail later in less helpful places, for example when constructing projection shapes or iterating over bit positions. I would explicitly require positive integer values, excluding bools, e.g.
if (
not isinstance(self.n_tables, (int, np.integer))
or isinstance(self.n_tables, bool)
or self.n_tables < 1
):
raise ValueError(...)
if (
not isinstance(self.n_bits_per_table, (int, np.integer))
or isinstance(self.n_bits_per_table, bool)
or not 1 <= self.n_bits_per_table <= 64
):
raise ValueError(...)|
Agreed, will make the adjustment with this and the distance arg for naive search. |
|
All done @TonyBagnall |
TonyBagnall
left a comment
There was a problem hiding this comment.
fantastic, good improvement
What does this implement/fix? Explain your changes.
Following the decisions made after #2473 and multiple discussions, this PR aims at clarifying the goal and interface of the similarity search module, notably by removing all components related to motif discovery, in order to not mix both intents even if they are related down the line.
This introduced a unique interface for all similarity search estimator, and focus on two use cases :
Both cases take as input a 3D array (a time series collection) during
fitand a 2D array (a subsequence or a whole series) duringpredict. Thepredictfunction returns two arraysindexes, distancesthat contain the indexes of the matches in the collection, as well as their distances to the 2D series.The goal is to validate this structure to be able to move the module out of experimental in the near future.
Content of the PR :
Module restructure
Estimators
API & internals
Testing
Docs & notebooks
Any other comments?
The code related to motif search has been deleted to simplify the intent and structure of the similarity search module. But a new motif search module would be a welcome addition later.
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
Notes :
Might need to add a "predict_batch" to handle collections in predict, as some algorithms can offer optimisation for predicting on collections. By default, it loops on the predict method for series, but child classes can override it for optimisations. This will be handled in a future PR.