diff --git a/pyFTS/common/fts.py b/pyFTS/common/fts.py index 17cb934..dd6f732 100644 --- a/pyFTS/common/fts.py +++ b/pyFTS/common/fts.py @@ -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 diff --git a/pyFTS/data/Bitcoin.py b/pyFTS/data/Bitcoin.py index 7d74d71..c0aaa64 100644 --- a/pyFTS/data/Bitcoin.py +++ b/pyFTS/data/Bitcoin.py @@ -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. diff --git a/pyFTS/data/DowJones.py b/pyFTS/data/DowJones.py index 8af9214..6afe4bb 100644 --- a/pyFTS/data/DowJones.py +++ b/pyFTS/data/DowJones.py @@ -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. diff --git a/pyFTS/data/Ethereum.py b/pyFTS/data/Ethereum.py index 35bdd69..6eb9949 100644 --- a/pyFTS/data/Ethereum.py +++ b/pyFTS/data/Ethereum.py @@ -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. diff --git a/pyFTS/models/hofts.py b/pyFTS/models/hofts.py index a5d4435..cb339f1 100644 --- a/pyFTS/models/hofts.py +++ b/pyFTS/models/hofts.py @@ -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): diff --git a/pyFTS/tests/general.py b/pyFTS/tests/general.py index 52e367f..1e9c775 100644 --- a/pyFTS/tests/general.py +++ b/pyFTS/tests/general.py @@ -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")