PYFTS / pyFTS

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

Performance of HOFTS on erratic dataset. #23

Open pintuiitbhi opened 5 years ago

pintuiitbhi commented 5 years ago

I trained a HOFTS with order 3 on erratic data. Dataset is montly. I predicted on train data and it looks like it has overfitted.

Here is the code:

from pyFTS.models import hofts, pwfts

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=[15,8])

ax.plot(train_uv[:100], label='Original')
rows = []
# for method in [hofts.HighOrderFTS, hofts.WeightedHighOrderFTS, pwfts.ProbabilisticWeightedFTS]:
for method in [hofts.HighOrderFTS]:
#     for order in [1, 2,3]:
    for order in [3]:
        model = method(partitioner=part, order=order)

        model.shortname += str(order)

        model.fit(train_uv)

        forecasts = model.predict(train_uv)
#         forecasts = model.predict([0,792,492], steps_ahead=142)
        forecast_fuzzy = forecasts
        for k in np.arange(order):
            forecasts.insert(0,None)

        ax.plot(forecasts[:100], label=model.shortname)

        models.append(model.shortname)

#         Util.persist_obj(model, model.shortname)

#         del(model)

handles, labels = ax.get_legend_handles_labels()
lgd = ax.legend(handles, labels, loc=2, bbox_to_anchor=(1, 1))  

I want to predict next 3 months data ie. 12 data points. How I can use the "predict" function to do this?

This is how I tried.

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=[15,8])

ax.plot(test_uv, label='Original')
forecasts = model.predict([1068,2280,4392], steps_ahead=12)
order = 3
for k in np.arange(order):
    forecasts.insert(0,None)
ax.plot(forecasts, label=model.shortname)
handles, labels = ax.get_legend_handles_labels()
lgd = ax.legend(handles, labels, loc=2, bbox_to_anchor=(1, 1))

test

Why is it remains constant after predicting 3 points in future?

[1068,2280,4392] is the last three data points of train dataset.

Originally posted by @pintuiitbhi in https://github.com/PYFTS/pyFTS/issues/6#issuecomment-499391674