johannfaouzi / pyts

A Python package for time series classification

Home Page:https://pyts.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MTF recreates Markov transition matrix on each transform call

EMplIFil opened this issue · comments

Description

MTF recreates the Markov transition matrix on each transform call using only the current batch of data. Shouldn't it be computed from the training set? (i.e. the dataset passed into the fit function).

I understand that the Markov transition field should be created from the data being transformed. But should the Markov transition matrix be recreated each time?

Steps/Code to Reproduce

<< your code here >>

Observe https://github.com/johannfaouzi/pyts/blob/main/pyts/image/mtf.py#L122

Versions

N/A

Concerning transformations, there is a big difference between standard machine learning and machine learning for time series: the transformation is often applied to each time series independently. This means that there is no need to fit the model on the training set because the fit method does nothing. Transforming a data set of N time series at once is equivalent to independently transforming each data set of 1 time series.

Let's take a very simple example: standardization (zero mean, unit variance). If your input data is a matrix whose rows are the samples and whose columns are the features:

  • In standard machine learning, you standardize each feature (column) independently: you need to learn the mean and the standard deviation of each feature during the training phase, and you apply the linear transformation during the inference phase.
  • In machine learning for time series, you standardize each time series (row) independently: you cannot (and don't need to) learn anything during the training phase because you have all the necessary information during the inference phase.

That's the same thing for Markov transition field: a Markov transition matrix is independently learned for each time series, then used to create the corresponding Markov transition field.

Ah yes, I see that there is a separate Markov transition matrix created for each individual sample, which makes more sense.

I guess I didn't think of that since the transition probabilities would be quite difficult to estimate given a short window which is normally what I work with.

Thanks for clarifying!