Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] dunders for time series distances and kernels (#3949)
This PR adds dunders for time series distances and kernels (descendants of `BasePairwiseTransformerPanel`), behaving as per likely user expectation, description as below. It also adds tests for the different combinations of dunders and estimators. ### algebraic operations between time series distances and kernels * `d = dist1 * dist2` satisfies `d(X1, X2) == dist1(X1, X2) * dist2(X1, X2)`, for all pairwise transformers `dist1`, `dist2`, equality for all elements of the resulting matrix * `d = dist1 + dist2` gives `d(X1, X2) == dist1(X1, X2) + dist2(X1, X2)`, for all pairwise transformers `dist1`, `dist2` * for a pairwise distance `dist` and an int or float `const`, `d = dist * const` or `d = const * dist` gives `d(X1, X2) == dist(X1, X2) * const` * for a pairwise distance `dist` and an int or float `const`, `d = dist + const` or `d = const + dist` gives `d(X1, X2) == dist(X1, X2) + const` ### pipeline concatenation between ordinary transformers and time series distances or kernels * for a transformer `trafo` and a pairwise `dist`, the esteimator `pipe = trafo * dist` is also a pairwise distance, with `pipe(X1, X2) == dist(trafo.fit_transform(X1), trafo.fit_transform(X2))` * above, the transformer `trafo` can be an `sktime` transformer, or an `sklearn` transformer (which is coerced/wrapped) This especially may be interesting for users with a research interest in time series classification or clustering, as it allows to obtain common time series distances easily as composition of others. E.g., ddtw (for common definitions of ddtw) is the same as `Differencer() * DtwDist()` (first difference, then dtw distance). Higher order differences or other combinations are also easy to obtain by this.
- Loading branch information
Showing
4 changed files
with
382 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.