The funcion predict() from DMD class is deprecated or not? #359
Replies: 7 comments
-
Dear @IvanPMorenoMarcos, the function To properly deal with univariate time series, I think you need the PS from a pure computational point of view, you can replace the "forecasting" loop and just use |
Beta Was this translation helpful? Give feedback.
-
Dear @ndem0, First of all, thank you for answering my questions. You mean that the DMD class is NOT apropriate to use when performing univariate time series forecasting? (please see these papers: https://doi.org/10.1016/j.apenergy.2019.114368 , https://doi.org/10.1016/j.apenergy.2018.09.190 using DMD for univariate forecasting). Or If I'm wrong, How can I use it for that task? In other words, how can I tune a DMD model? Is there a approach to do that? (give me a tip if possible please). Nowadays I'm attempting to use it in my PhD work. Best regards! |
Beta Was this translation helpful? Give feedback.
-
Dear @ndem0, Here: https://github.com/IvanPMorenoMarcos/Dynamic-Mode-Decomposition-for-one-step-ahead-univariate-time-series-forecasting.git you can find my code using a DMD model for univariate time series forecasting. See the file: dmd.ipynb. |
Beta Was this translation helpful? Give feedback.
-
Dear @ndem0, Here you can find my try on using HODMD for univariate time series forecasting. Please, Can you review my code? (See the file: hodmd.ipynb). I want to perform one-step ahead forecasting. I thank you in advance for the time used! |
Beta Was this translation helpful? Give feedback.
-
@IvanPMorenoMarcos just change tend by adding the number of timesteps you want to predict in the future. For example if the train has 100 time instants and the test 20, dmd_time['tend'] += 20 |
Beta Was this translation helpful? Give feedback.
-
@mtezzele thanks for your help. I did that as: set forecasting horizon
Is it that correct? If not, how can I fix it? Thanks for advance. |
Beta Was this translation helpful? Give feedback.
-
You need to increase it. That dictionary tells you the starting time, the time step and the final time. You need to change only the final time (+20 for example) to reconstruct all the snapshots and predict 20 more. If you have other doubts I suggest you also to have a look at the first 2 tutorials. |
Beta Was this translation helpful? Give feedback.
-
The function predicti() can be find in https://mathlab.github.io/PyDMD/dmd.html#
My question is, that function is correct? because I'm using to predict one-step ahead on a univariate time series (airline passengers).
This is my code:
one-step ahead univariate forecasting using a DMD model
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from pydmd import DMD
load training dataset
training = pd.read_csv('airline_passengers_training.csv', index_col=0, header=None, parse_dates=True, squeeze=True)
create and fit a DMD model
dmd = DMD(svd_rank=-1,
opt=True,
exact=True,
rescale_mode=None,
forward_backward=True,
tlsq_rank=1,
sorted_eigs=False)
dmd.fit(training.values)
perform forecasts on training dataset
x = training.values
x = x.reshape((len(x),1))
forecasts = []
for i in range(len(x)):
x_i = x[i].reshape((1,1))
yhat = dmd.predict(x_i)
forecasts.append(yhat)
forecasts = np.array(forecasts).ravel()
plot predicted vs actuals on training dataset
plt.plot(training.values, label='Actuals')
plt.plot(forecasts, label='Predictions')
plt.legend()
plt.show()
The forecasts are very similar to the actuals points. I think that, there's something wrong on my code or in the function.
Best regards.
Beta Was this translation helpful? Give feedback.
All reactions