Bugfix in forecast_ahead

This commit is contained in:
Petrônio Cândido 2019-07-05 08:02:33 -03:00
parent 07832878c9
commit 0b03fbfa57
2 changed files with 14 additions and 7 deletions

View File

@ -239,9 +239,9 @@ class FTS(object):
start = kwargs.get('start_at',0) start = kwargs.get('start_at',0)
ret = [] ret = data[:start+self.max_lag]
for k in np.arange(start+self.max_lag, steps+start+self.max_lag): for k in np.arange(start+self.max_lag, steps+start+self.max_lag):
tmp = self.forecast(data[k-self.max_lag:k], **kwargs) tmp = self.forecast(ret[k-self.max_lag:k], **kwargs)
if isinstance(tmp,(list, np.ndarray)): if isinstance(tmp,(list, np.ndarray)):
tmp = tmp[-1] tmp = tmp[-1]
@ -364,7 +364,7 @@ class FTS(object):
if dump == 'time': if dump == 'time':
print("[{0: %H:%M:%S}] Start training".format(datetime.datetime.now())) print("[{0: %H:%M:%S}] Start training".format(datetime.datetime.now()))
if num_batches is not None: if num_batches is not None and not self.is_wrapper:
n = len(data) n = len(data)
batch_size = int(n / num_batches) batch_size = int(n / num_batches)
bcount = 1 bcount = 1

View File

@ -29,12 +29,19 @@ from pyFTS.partitioners import Grid
partitioner = Grid.GridPartitioner(data=train_data, npart=35) partitioner = Grid.GridPartitioner(data=train_data, npart=35)
from pyFTS.models import pwfts from pyFTS.models import pwfts, hofts
model = pwfts.ProbabilisticWeightedFTS(partitioner=partitioner, order=2) #model = pwfts.ProbabilisticWeightedFTS(partitioner=partitioner, order=2)
model.train(train_data) #from pyFTS.models.incremental import TimeVariant
print(model.predict(test_data[:100])) #model = TimeVariant.Retrainer(partitioner_method=Grid.GridPartitioner, partitioner_params={'npart': 35},
# fts_method=pwfts.ProbabilisticWeightedFTS, fts_params={}, order=2 ,
# batch_size=100, window_length=500)
model = hofts.HighOrderFTS(partitioner=partitioner, order=2)
model.fit(train_data)
print(model.predict(test_data, steps_ahead=10))
''' '''