PYFTS / pyFTS

An open source library for Fuzzy Time Series in Python
http://pyfts.github.io/pyFTS/
GNU General Public License v3.0
262 stars 54 forks source link

One step forecasting #28

Open smejiame opened 4 years ago

smejiame commented 4 years ago

Hello Petronio,

I am testing the fuzzy time series model to forecast one period ahead of a time series with order 12. I am starting with a basic model: using a 20-grid partitioner, mf = triangle, chen model.

My code is: ts = datos['y'].dropna().to_numpy() fs = Grid.GridPartitioner(data = ts, npart = 20) model = chen.ConventionalFTS(partitioner = fs) model.fit(ts, order = 15) forecast = model.predict(ts)

I'm getting a forecast array which length = len(ts), I have checked other posts, and I realized that the result is the one-step ahead forecast for each period, i.e. forecast[0] is the prediction that compares with ts[1] , forecast[1] is the prediction that compares with ts[2]...

My question here is: how I am getting a result in the first 12 values, since my model's order is 12?

These are the first 12 values that I am getting:

[0.3270031616601807, 0.3270031616601807, 0.3270031616601807, 0.3270031616601807, 0.09897023952868034, 0.3270031616601807, 0.3270031616601807, 0.09897023952868034, -0.28108463069048684, -0.2810846306904869, 0.09897023952868034, 0.3270031616601807, ...]

Thanks for the help

petroniocandido commented 4 years ago

Hi @smejiame !

Sorry for the long delay. Well... Order 12? Are you sure that this is really needed? The training process will be very long and the final model will be huge! In the greater majority of cases, 3 lags are enough to detect more complex patterns. Pay attention to the 'lags' parameter, where you can inform which the lag indexes [if they are different from the last 3 lags, for example]

BUT if you really want a 12th order model, so you input data must have at least 12 items [one for each order of the model]. Do you check if your input is correct?

Best regards

smejiame commented 4 years ago

Actually, the order 12 is because the seasonality, so you are right in the sense that it is better toinform the lag indexes (1, 6, and 12 in my case). The size of my input data is above 3.000 observations, so the question is not about the length since it is enough, the question is: why I am getting a prediction in the first 12 observations? for example, observation #5, should use observation 4, observation -1 and observation -7, so, If I compare it with an ARIMA: in an ARIMA, I will get predictions for observation #13, and so on, not for the first 12 predictions, but in this case, I am getting predictions for the first observations.