tslearn-team / tslearn

The machine learning toolkit for time series analysis in Python
https://tslearn.readthedocs.io
BSD 2-Clause "Simplified" License
2.89k stars 337 forks source link

Implement metric learning for time series #8

Open rtavenar opened 7 years ago

rtavenar commented 7 years ago

It would make sense to have metric learning algos dedicated to time series in tslearn.

A good start could be Garreau et al, 2014, but maybe other methods could make more sense.

smarie commented 4 years ago

If you need help on this topic I happen to have a bit of experience: https://tel.archives-ouvertes.fr/tel-01678889v1/document

In particular several topics from this manuscript could be included in tslearn:

It is much easier to implement 2.3 (unimodal metrics) and 3.3.3 (multi-scale generation of metrics) first, as the metric learning per se (section 3) is heavy in terms of computation/data representation (pairwise space) and optimization methods.

rtavenar commented 4 years ago

Hi @smarie

Definitely! Your expertise would be a great help to the tslearn team!

Concerning metric learning, it would be nice (I guess, I'm not an expert on the topic, though I'd like to learn :) to have both your method and Garreau's one included in tslearn, don't you think? Do you know of other standard competitors that should be considered? Do you think you could give a hand on integration of one or both methods into tslearn?

Best, Romain

smarie commented 4 years ago

Do you know of other standard competitors that should be considered?

There seem to be three families of approaches to metric learning for time series:

There is also the topic of task: metric learning... for what? Alignment ? Classification ? etc. Some of these tasks are standard sklearn ones but some others are not, we should define them.

It is already old (2017) but you can check the biblio of our subsequent IS journal paper to get a list of methods in both categories. There were many already so I would not be surprised that there are more now.

I'm not familiar with Garreau's method but after looking through it briefly, it seems to belong to the first category.

Our method belongs to the second category: it is generic as it learns an optimal metric that is a linear or non-linear combination of basic metrics. So you can use any set of basic metrics of your choice, not necessarily the ones we propose, and not necessarily metrics for timeseries. In the paper we propose basic metrics that form a multi-modal (amplitude, shape, spectrum), multi-scale set to compare timeseries. But you could use any number of alternate basic metrics instead.

it would be nice (I guess, I'm not an expert on the topic, though I'd like to learn :) to have both your method and Garreau's one included in tslearn. [...] Do you think you could give a hand on integration of one or both methods into tslearn?

Well I would be glad to see our method available in tslearn but I'm afraid it requires quite some bandwidth, which to be honest I do not have for now. Also this discussion made me have some questions about the best place to put each piece.

At this point I would suggest

What do you think ? Sorry for opening this in many different directions but your direct question triggered quite a bit of implementation-related thinking :)

rtavenar commented 4 years ago

OK, thank you for the very detailed answer. I agree that tslearn should focus on time series specific methods, and metric-learn is probably a better place for generic metric learning methods.

So, what I suggest is that we focus on Garreau's method for a start on metric learning in tslearn, with the goal of following metric-learn API, of course.

Then, if your method is implemented in metric-learn, a second step would be to add the similarity measure corT in tslearn and see how the global metric learning method could be run using both metric-learn and tslearn, but that seems to be for a later stage.

Anyway, if anyone is willing to work on implementation of Garreau's method, that would be great!

smarie commented 4 years ago

Thanks for the quick answer @rtavenar ! I'll investigate and keep you posted when I have interesting news on this topic.