PyDMD icon indicating copy to clipboard operation
PyDMD copied to clipboard

DMD reconstructed data not fitting the last point in train dataset.

Open ovgeorge opened this issue 4 years ago • 5 comments

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()

ovgeorge avatar May 12 '21 12:05 ovgeorge

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.

fandreuz avatar May 12 '21 18:05 fandreuz

svd_rank is equal to the number of sample vectors, tlsq_rank = number of sumples - 1

Other parameters provide worse fit.

ovgeorge avatar May 13 '21 19:05 ovgeorge

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.

ndem0 avatar May 18 '21 08:05 ndem0

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?

ovgeorge avatar May 18 '21 19:05 ovgeorge

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

fandreuz avatar May 18 '21 21:05 fandreuz

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 :)

mtezzele avatar Mar 28 '23 15:03 mtezzele