diff --git a/pyFTS/models/multivariate/mvfts.py b/pyFTS/models/multivariate/mvfts.py index 31f2fa1..4522e92 100644 --- a/pyFTS/models/multivariate/mvfts.py +++ b/pyFTS/models/multivariate/mvfts.py @@ -38,7 +38,11 @@ class MVFTS(fts.FTS): def apply_transformations(self, data, params=None, updateUoD=False, **kwargs): ndata = data.copy(deep=True) for var in self.explanatory_variables: - ndata[var.data_label] = var.apply_transformations(data[var.data_label].values) + if self.uod_clip: + ndata[var.data_label] = np.clip(ndata[var.data_label].values, + var.partitioner.min, var.partitioner.max) + + ndata[var.data_label] = var.apply_transformations(ndata[var.data_label].values) return ndata @@ -130,7 +134,6 @@ class MVFTS(fts.FTS): def forecast_ahead(self, data, steps, **kwargs): generators = kwargs.get('generators',None) - start = kwargs.get('start', 0) if generators is None: raise Exception('You must provide parameter \'generators\'! generators is a dict where the keys' + diff --git a/pyFTS/tests/multivariate.py b/pyFTS/tests/multivariate.py index 1f81523..3f0898b 100644 --- a/pyFTS/tests/multivariate.py +++ b/pyFTS/tests/multivariate.py @@ -87,13 +87,29 @@ train_split = 24 * 800 train_mv = dataset.iloc[:train_split] test_mv = dataset.iloc[train_split:] +#model = Util.load_obj('/home/petronio/Downloads/ClusteredMVFTS4') + + + vhour = variable.Variable("Hour", data_label="hour", partitioner=seasonal.TimeGridPartitioner, npart=24, data=dataset, partitioner_specific={'seasonality': DateTime.hour_of_day, 'type': 'common'}) -vprice = variable.Variable("Price", data_label="price", partitioner=Grid.GridPartitioner, npart=10, +vprice = variable.Variable("Price", data_label="price", partitioner=Grid.GridPartitioner, npart=55, data=train_mv) +model = cmvfts.ClusteredMVFTS(order=2, knn=3) +model.append_variable(vhour) +model.append_variable(vprice) +model.target_variable = vprice +model.fit(train_mv) + +data = [[1, 1.0], [2, 2.0]] + +df = pd.DataFrame(data, columns=['hour','price']) + +forecasts = model.predict(df, steps_ahead=24, generators={'Hour': lambda x : (x+1)%24 }) +''' params = [ {}, {}, @@ -114,4 +130,4 @@ for ct, method in enumerate([mvfts.MVFTS, wmvfts.WeightedMVFTS, cmvfts.Clustered #print(model1.predict(test_mv, steps_ahead=24, generators={'Hour': lambda x : (x+1)%24 })) -#""" \ No newline at end of file +''' \ No newline at end of file