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

How the predict function works? #22

Closed pintuiitbhi closed 5 years ago

pintuiitbhi commented 5 years ago

Case 1: forecasts = model.predict([1020,3840,1920], steps_ahead=9) Where [1020,3840,1920] is the last 3 data point of time series in "train_uv" Case 2: forecasts = model.predict(train_uv, steps_ahead=9)

Both are giving different forecast i.e 9 future data points.

How the predict function is working in these two cases above?

petroniocandido commented 5 years ago

In order to reproduce the problem, could you please share the code and data you used?

pintuiitbhi commented 5 years ago

Actually, I don't have permission to share the dataset. But you can take any erratic dataset and work on it.

According to me this is how "predict" function is working:

Case 1: (Order =3 and model is HOFTS | Grid partition | triangular membership| 35 partitions)

forecasts = model.predict([1020,3840,1920], steps_ahead=9) The predict function with take [1020,3840,1920] values and predict the next one. Let's say 864. Now predict will use [3840, 1920, 864] to predict the next values. Let it be 950. Again predict will use [1920, 864, 950] to predict the next value. And so on till we get 9 future data points.

Case 2:

forecasts = model.predict(train_uv, steps_ahead=9) Here predict will extract the last 3 data points i.e [1020,3840,1920] from "train_uv" and it will use these three values to find the next one as we did above in Case 1.

Am I right?

petroniocandido commented 5 years ago

On predict function, when using the steps_ahead parameter, you may also have to use the start_at parameter, in case you don't want to start forecasting at the beginning of the input data. Please also verify if your installed version of pyFTS is the most recent version.

pintuiitbhi commented 5 years ago

Please also verify if your installed version of pyFTS is the most recent version.

It is the lastest one (1.6).

What I said about "predict" function , is it correct? https://github.com/PYFTS/pyFTS/issues/22#issuecomment-499540269

I tried "starts_at" in "predict" function result is same whether I use it or not. forecasts = model.predict(train_uv,starts_at = 145, steps_ahead=9) Where 144 is the index of last element in "train_uv". Though I tried starts_at = 144 also. But result is still same. Same as of : forecasts = model.predict(train_uv, steps_ahead=9)

petroniocandido commented 5 years ago

If using start_at (not starts_at) do not change the response, probably your version is not the last, try updating it directly from the git repository.

Your understanding about the predict funciont (in case 1) is correct. But in case 2 the function will pick not the last, but the first lags of data. Please let me know in case it does not work for you.

pintuiitbhi commented 5 years ago

Whether I use

Case 1:

forecastsTest= model.predict(train_uv, start_at=144, steps_ahead=12) or

Case 2:

forecastsTest = model.predict(train_uv, steps_ahead=12)

Both gives the same "forecastTest".

What does actually "start_at" do?

Is the following intrepretation of "predict" function correct? In case 2, predict function will pick first 3 (Suppose order of hofts is 3) data points from "train_uv" and starts predicting. Next 12 points it will predict. In case 1, predict will pick 3 data points starting from index 144 ie. elements at index 144, 145, 146 and starts predicting the next 12 data points.

pintuiitbhi commented 5 years ago

Order = 5

Output waveform of predict in forecasts = model.predict(train_uv) this case is: tr

Output waveform of predict in forecasts = model.predict(train_uv[:5],steps_ahead=139) this case is: tr2

Your understanding about the predict funciont (in case 1) is correct. But in case 2 the function will pick not the last, but the first lags of data.

If forecasts = model.predict(train_uv) picks the first 5 lags the output of both should be same. How is prediction so perfect in this forecasts = model.predict(train_uv) ?

petroniocandido commented 5 years ago

I will try to simulate this issue on HOFTS method. However, apparently you data have seasonality (+/- at every 20 instances). Have you tried to use multivariate methods for that (MVFTS, WMVFTS, etc) ?