Bugfixes in FTS.forecast_ahead
This commit is contained in:
parent
033dc2807a
commit
9e0a4e312f
@ -189,15 +189,19 @@ class FTS(object):
|
|||||||
:param kwargs: model specific parameters
|
:param kwargs: model specific parameters
|
||||||
:return: a list with the forecasted values
|
:return: a list with the forecasted values
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if isinstance(data, np.ndarray):
|
||||||
|
data = data.tolist()
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
for k in np.arange(0,steps):
|
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)):
|
if isinstance(tmp,(list, np.ndarray)):
|
||||||
tmp = tmp[0]
|
tmp = tmp[-1]
|
||||||
|
|
||||||
ret.append(tmp)
|
ret.append(tmp)
|
||||||
data.append_rhs(tmp)
|
data.append(tmp)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import pandas as pd
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def get_data(field='avg'):
|
def get_data(field='AVG'):
|
||||||
"""
|
"""
|
||||||
Get the univariate time series data.
|
Get the univariate time series data.
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import pandas as pd
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def get_data(field='avg'):
|
def get_data(field='AVG'):
|
||||||
"""
|
"""
|
||||||
Get the univariate time series data.
|
Get the univariate time series data.
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import pandas as pd
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def get_data(field='avg'):
|
def get_data(field='AVG'):
|
||||||
"""
|
"""
|
||||||
Get the univariate time series data.
|
Get the univariate time series data.
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class HighOrderFTS(fts.FTS):
|
|||||||
|
|
||||||
l = len(ndata)
|
l = len(ndata)
|
||||||
|
|
||||||
if l <= self.max_lag:
|
if l < self.max_lag:
|
||||||
return ndata
|
return ndata
|
||||||
|
|
||||||
for k in np.arange(self.max_lag, l+1):
|
for k in np.arange(self.max_lag, l+1):
|
||||||
|
@ -19,7 +19,7 @@ dataset = TAIEX.get_data()
|
|||||||
#print(len(dataset))
|
#print(len(dataset))
|
||||||
|
|
||||||
from pyFTS.partitioners import Grid, Util as pUtil
|
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
|
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 import pwfts, song, chen, ifts, hofts
|
||||||
from pyFTS.models.ensemble import ensemble
|
from pyFTS.models.ensemble import ensemble
|
||||||
|
|
||||||
model = chen.ConventionalFTS(partitioner=partitioner)
|
print(partitioner)
|
||||||
#model = hofts.HighOrderFTS(partitioner=partitioner,order=2)
|
|
||||||
model.append_transformation(tdiff)
|
|
||||||
model.fit(dataset[:800])
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
print(model.predict([3500, 7000], steps_ahead=5))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#cUtil.plot_rules(model, size=[20,20], rules_by_axis=5, columns=1)
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
print("fim")
|
print("fim")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user