Bugfixes in FTS.forecast_ahead

This commit is contained in:
Petrônio Cândido 2018-09-10 10:33:47 -03:00
parent 033dc2807a
commit 9e0a4e312f
6 changed files with 25 additions and 13 deletions

View File

@ -189,15 +189,19 @@ class FTS(object):
:param kwargs: model specific parameters
:return: a list with the forecasted values
"""
if isinstance(data, np.ndarray):
data = data.tolist()
ret = []
for k in np.arange(0,steps):
tmp = self.forecast(data[-self.order:], **kwargs)
tmp = self.forecast(data[-self.max_lag:], **kwargs)
if isinstance(tmp,(list, np.ndarray)):
tmp = tmp[0]
tmp = tmp[-1]
ret.append(tmp)
data.append_rhs(tmp)
data.append(tmp)
return ret

View File

@ -12,7 +12,7 @@ import pandas as pd
import numpy as np
def get_data(field='avg'):
def get_data(field='AVG'):
"""
Get the univariate time series data.

View File

@ -12,7 +12,7 @@ import pandas as pd
import numpy as np
def get_data(field='avg'):
def get_data(field='AVG'):
"""
Get the univariate time series data.

View File

@ -12,7 +12,7 @@ import pandas as pd
import numpy as np
def get_data(field='avg'):
def get_data(field='AVG'):
"""
Get the univariate time series data.

View File

@ -117,7 +117,7 @@ class HighOrderFTS(fts.FTS):
l = len(ndata)
if l <= self.max_lag:
if l < self.max_lag:
return ndata
for k in np.arange(self.max_lag, l+1):

View File

@ -19,7 +19,7 @@ dataset = TAIEX.get_data()
#print(len(dataset))
from pyFTS.partitioners import Grid, Util as pUtil
partitioner = Grid.GridPartitioner(data=dataset[:800], npart=10, transformation=tdiff)
partitioner = Grid.GridPartitioner(data=dataset[:2000], npart=20) #, transformation=tdiff)
from pyFTS.common import Util as cUtil
@ -28,15 +28,23 @@ from pyFTS.benchmarks import benchmarks as bchmk, Util as bUtil, Measures, knn,
from pyFTS.models import pwfts, song, chen, ifts, hofts
from pyFTS.models.ensemble import ensemble
model = chen.ConventionalFTS(partitioner=partitioner)
#model = hofts.HighOrderFTS(partitioner=partitioner,order=2)
model.append_transformation(tdiff)
model.fit(dataset[:800])
print(partitioner)
cUtil.plot_rules(model, size=[20,20], rules_by_axis=5, columns=1)
#model = chen.ConventionalFTS(partitioner=partitioner)
model = hofts.HighOrderFTS(partitioner=partitioner,order=2)
#model.append_transformation(tdiff)
model.fit(dataset[:2000])
print(model)
print(model.predict([3500, 7000], steps_ahead=5))
#cUtil.plot_rules(model, size=[20,20], rules_by_axis=5, columns=1)
#
print("fim")