-
Notifications
You must be signed in to change notification settings - Fork 62
How does one add DTW to metrics? #363
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
Comments
First, I will explain things as they are in the current development branch, as we will release it as a new version in a few days. Remember that with pip you can install a package from a Github branch, even if it has not yet been released in PyPI. A metric is a Python callable with the following definition (in your case class Metric(Protocol[MetricElementType]):
"""Protocol for a metric between two elements of a metric space."""
@abstractmethod
def __call__(
self,
__e1: MetricElementType,
__e2: MetricElementType,
) -> np.ndarray:
pass It receives two You can either create a function with the prototype of In order to implement the function, you probably will need to access the I am not familiar with That would be enough to use it. If you want to optimize also the pairwise computation of that metric, it is also possible to override the default pair-by-pair computation, as it is done for the L2 case here: scikit-fda/skfda/misc/metrics/_lp_distances.py Lines 98 to 136 in cf71fad
I also wanted to say that if it is easier for you, scikit-fda is designed to be as compatible as possible with scikit-learn, and we reuse its hyperparameter tuning utilities. You can even mix both in the same Pipeline, see here for examples: https://fda.readthedocs.io/en/latest/auto_tutorial/plot_skfda_sklearn.html Note that as |
First of all let me thank you for this package, and say: great work!
Is your feature request related to a problem? Please describe.
I am working with timeseries data. For now I have applied K-means with L2 norm with okay-ish results, however I wanted to try other distance functions to see if these results could be improved. This distance is already implemented in the package
dtw-python
. After some hours I haven't been able to make FDA K-means work with dtw, I have been trying to wrap the function but I am at a loss without knowing more about the inner workings of your library.Describe the solution you'd like
Some documentation on how to adapt pre-existing distance functions to your API. I am willing to contribute code if some guidance is provided.
Describe alternatives you've considered
I have considered switching to
scikit-learn
. After all, DTW is meant for timeseries data so the functional approach that skfda provides isn't as critical as when applying Euclidean distance. I however think that in order to automate the process and do hyperparameter optimization, it's better if I only use skfda.Additional context
The text was updated successfully, but these errors were encountered: