From 2db3b0311ed7fd99167f20263248923e6dd2615d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Tue, 13 Nov 2018 18:54:18 -0200 Subject: [PATCH] uod_clip on mvfts models --- pyFTS/models/multivariate/mvfts.py | 7 +++++-- pyFTS/tests/multivariate.py | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) 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