Bugfix on MVFTS.forecast_ahead
This commit is contained in:
parent
c7dd392575
commit
8818cfe529
@ -67,7 +67,9 @@ class ClusteredMVFTS(mvfts.MVFTS):
|
|||||||
|
|
||||||
ndata = self.check_data(ndata)
|
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):
|
def forecast_multivariate(self, data, **kwargs):
|
||||||
|
|
||||||
|
@ -170,11 +170,11 @@ class MVFTS(fts.FTS):
|
|||||||
|
|
||||||
ndata = self.apply_transformations(data)
|
ndata = self.apply_transformations(data)
|
||||||
|
|
||||||
start = kwargs.get('start_at', self.order)
|
start = kwargs.get('start_at', self.max_lag)
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
for k in np.arange(0, steps):
|
for k in np.arange(start, start+steps):
|
||||||
ix = ndata.index[start-self.max_lag+k:k+start]
|
ix = ndata.index[k-self.max_lag:k]
|
||||||
sample = ndata.loc[ix]
|
sample = ndata.loc[ix]
|
||||||
tmp = self.forecast(sample, **kwargs)
|
tmp = self.forecast(sample, **kwargs)
|
||||||
|
|
||||||
@ -200,9 +200,12 @@ class MVFTS(fts.FTS):
|
|||||||
|
|
||||||
new_data_point[self.target_variable.data_label] = tmp
|
new_data_point[self.target_variable.data_label] = tmp
|
||||||
|
|
||||||
|
print(k)
|
||||||
|
print(new_data_point)
|
||||||
|
|
||||||
ndata = ndata.append(new_data_point, ignore_index=True)
|
ndata = ndata.append(new_data_point, ignore_index=True)
|
||||||
|
|
||||||
return ret[-steps]
|
return ret[-steps:]
|
||||||
|
|
||||||
def forecast_interval(self, data, **kwargs):
|
def forecast_interval(self, data, **kwargs):
|
||||||
ret = []
|
ret = []
|
||||||
|
@ -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)
|
fs = grid.GridCluster(explanatory_variables=[vmonth, vhour, vavg], target_variable=vavg)
|
||||||
model = cmvfts.ClusteredMVFTS(explanatory_variables=[vmonth, vhour, vavg], target_variable=vavg, partitioner=fs,
|
model = cmvfts.ClusteredMVFTS(explanatory_variables=[vmonth, vhour, vavg], target_variable=vavg, partitioner=fs,
|
||||||
order=2, knn=1)
|
order=2, knn=1)
|
||||||
|
#model = wmvfts.WeightedMVFTS(explanatory_variables=[vmonth, vhour, vavg], target_variable=vavg)
|
||||||
|
|
||||||
model.fit(train_mv)
|
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)
|
print(forecasts)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user