Inverse transform for dimensionality reduction algos
astrogilda opened this issue · comments
Description
Hello! Is there a way to inverse_transform any of the 'approximation' methods? I have a dataset of simple 20,0001D timeseries only 30 units long (i.e., [20,000 x 30]) and I want to reduce this to say 5 (i.e. to [20,000 x 5]). So far I have been using PCA and kernel PCA, neither of which are meant for time series work, and I would like to compare performance with the various algorithms in this package, but unfortuantely I did not find a way to inverse-transform the reduced time series.
Steps/Code to Reproduce
<< your code here >>
Versions
Hi,
Sorry for the delayed response. In the approximation
submodule there are two kinds of algorithms:
- Algorithms that decrease the dimension of the second axis (let's say from
R^n
toR^p
withp < n
andR
the set of real numbers):- pyts.approximation.PiecewiseAggregateApproximation decreases the number of time points by taking the mean values over a sliding window.
- pyts.approximation.DiscreteFourierTransform extracts some Fourier coefficients.
- Algorithms that decrease the set itself (let's say from
R^n
toS^n
withS
being a subset ofR
):- pyts.approximation.MultipleCoefficientBinning bins data over the second axis (often used on Fourier coefficients).
- pyts.approximation.SymbolicAggregateApproximation bins data over the first axis (often used after PAA reduction).
Finally pyts.approximation.SymbolicFourierApproximation is the pipeline of pyts.approximation.DiscreteFourierTransform followed by pyts.approximation.MultipleCoefficientBinning.
It's also important to note most of these algorithms learn the approximation of each time series independently, and therefore these algorithms do not learn to reduce the original feature space (like PCA or KernelPCA that learn a projection of the original feature space onto a subspace).
Back to your question, it means that:
- pyts.approximation.PiecewiseAggregateApproximation can have an inverse transformation, but it's a very trivial one (you would repeat the values and get a piecewise linear time series)
- pyts.approximation.DiscreteFourierTransform can have an inverse transformation (see this example)
- pyts.approximation.SymbolicAggregateApproximation cannot have an inverse transformation because it learns the transformation of specific time series, not a general transformation of the feature space.
- pyts.approximation.MultipleCoefficientBinning can have an inverse transformation (by taking the mean value in each bin for instance)
- pyts.approximation.SymbolicFourierApproximation can have a inverse transformation because both pyts.approximation.DiscreteFourierTransform and pyts.approximation.MultipleCoefficientBinning can.
I will try work on this in the near future! Let me know what you think.
Best,
Johann