Bugfix on MVFTS.forecast_ahead

This commit is contained in:
Petrônio Cândido 2019-06-17 10:57:09 -03:00
parent c7dd392575
commit 8818cfe529
3 changed files with 13 additions and 6 deletions

View File

@ -67,7 +67,9 @@ class ClusteredMVFTS(mvfts.MVFTS):
ndata = self.check_data(ndata)
return self.model.forecast(ndata, fuzzyfied=self.pre_fuzzyfy, **kwargs)
pre_fuzz = kwargs.get('pre_fuzzyfy', self.pre_fuzzyfy)
return self.model.forecast(ndata, fuzzyfied=pre_fuzz, **kwargs)
def forecast_multivariate(self, data, **kwargs):

View File

@ -170,11 +170,11 @@ class MVFTS(fts.FTS):
ndata = self.apply_transformations(data)
start = kwargs.get('start_at', self.order)
start = kwargs.get('start_at', self.max_lag)
ret = []
for k in np.arange(0, steps):
ix = ndata.index[start-self.max_lag+k:k+start]
for k in np.arange(start, start+steps):
ix = ndata.index[k-self.max_lag:k]
sample = ndata.loc[ix]
tmp = self.forecast(sample, **kwargs)
@ -200,9 +200,12 @@ class MVFTS(fts.FTS):
new_data_point[self.target_variable.data_label] = tmp
print(k)
print(new_data_point)
ndata = ndata.append(new_data_point, ignore_index=True)
return ret[-steps]
return ret[-steps:]
def forecast_interval(self, data, **kwargs):
ret = []

View File

@ -63,9 +63,11 @@ vavg = variable.Variable("Radiation", data_label="glo_avg", alias='rad',
fs = grid.GridCluster(explanatory_variables=[vmonth, vhour, vavg], target_variable=vavg)
model = cmvfts.ClusteredMVFTS(explanatory_variables=[vmonth, vhour, vavg], target_variable=vavg, partitioner=fs,
order=2, knn=1)
#model = wmvfts.WeightedMVFTS(explanatory_variables=[vmonth, vhour, vavg], target_variable=vavg)
model.fit(train_mv)
forecasts = model.predict(test_mv.iloc[:100])
generator = lambda x : x + pd.to_timedelta(1, unit='h')
forecasts = model.predict(test_mv.iloc[:3], steps_ahead=48, generators={'data': generator} )
print(forecasts)