DMD reconstructed data not fitting the last point in train dataset.
I have problem like this with not fitting the last point in the train https://imgur.com/QW5zWEd when all I do is
dmd = pydmd.DMD(**dmd_opts)
dmd.fit(train_flattened)
fit = dmd.reconstructed_data.copy()
Could you please show the content of dmd_opts? If you take too many DMD modes you may be including divergent dynamics in your reconstruction.
svd_rank is equal to the number of sample vectors, tlsq_rank = number of sumples - 1
Other parameters provide worse fit.
Dear @ovgeorge, in short, the parameters you are using gives you a nice reconstruction since you are using the maximum number of modes. The problem with the last snapshot is that probably you have some unstable modes which makes the prediction in the last timestep problematic. I suppose that if you try to predict in future, the error exponentially grows. Looking at your plot, I think that decomposing such functions (is it scalar?) with DMD can be very tricky.
Yes, error growths at least polynomially fast, but what I found to be surprising is that simple autoregression model produces better prediction. What can be done with unstable modes?
There are some tools to select an acceptable number of singular values automatically. You can set the parameter svd_rank of the constructor DMD(...) to:
- 0 for an optimal rank;
- a float in the interval
(0,1)to select only the singular values needed to reach the "energy"svd_rank. Using one of these values usually reduces the impact of unstable modes, but it's not guaranteed: it depends on the problem.
If your function is scalar you may be interested in this PyDMD tutorial: https://github.com/mathLab/PyDMD/blob/master/tutorials/tutorial-6-hodmd.ipynb
This is probably related to the use of exact or projected modes. You should see a difference in the reconstruction of the last snapshot. I hope this add something to the discussion :)