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

adjust number of lags #12

Closed jermaine1ronquillo closed 6 years ago

jermaine1ronquillo commented 6 years ago

It is mentioned in your tutorial, A short tutorial on Fuzzy Time Series, the lag used in the example used t-1 lag, how do we adjust the number of lags using pyFTS?

Regards,

petroniocandido commented 6 years ago

The number of lags can be chosen when you employ an high order method, like HOFTS (the standard), IFTS or PWFTS. In that cases you can inform the order (the number of lags) in the constructor using the 'order' parameter and the lag indexes using the 'lags' parameter. The default 'order' is 2 and the default 'lags' is [1,2]. Check the below the model creation for third order and lags 7,14,21:

from pyFTS.data import SONDA from pyFTS.partitioners import Grid from pyFTS.models import hofts

train = SONDA.get_data('glo_avg')[:800] test = SONDA.get_data('glo_avg')[800:1000]

partitioner = Grid.GridPartitioner(data=train, npart=35)

model = hofts.HighOrderFTS(partitioner=partitioner, order=3, lags=[7, 14, 21])

model.fit(train)

print(model)

forecasts = model.predict(test)

jermaine1ronquillo commented 6 years ago

Thank you for the reply. Based on my understanding if the default order is 2 then I must specify a list with two values of lag. And on the example above the order is 3 that is why the lag has a value of three lags. If the order is 4 or more then lag has four or more values too? Second question is how do we identify or determine the number of lags per order ( I assume ACF/PACF, but how?)?

Regards,

petroniocandido commented 6 years ago

Hi! You don't need to specify the lags, it is automatically generated as an incremental list. It is the default and it works for the majority of the situations. BUT sometimes there are more significant lags that help to identify complex patterns. In that case you must use the 'lags' parameter. ACF is a good start, but it won't work always, specially for long memory time series. I am currently working on a hyperparameter optimization tool that helps to identify the best lags.

jermaine1ronquillo commented 6 years ago

Great! My focus at the moment is long time series, I hope the tool will be available soon.

Regards,