From 07832878c928caf3ed7d2a9913ccb8fbf4ea2104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Wed, 3 Jul 2019 20:19:30 -0300 Subject: [PATCH] Bugfix on FTS.clip_uod --- pyFTS/common/fts.py | 4 +++- pyFTS/tests/multivariate.py | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pyFTS/common/fts.py b/pyFTS/common/fts.py index 2440463..e1f61e8 100644 --- a/pyFTS/common/fts.py +++ b/pyFTS/common/fts.py @@ -89,7 +89,9 @@ class FTS(object): return best def clip_uod(self, ndata): - if self.uod_clip: + if self.uod_clip and self.partitioner is not None: + ndata = np.clip(ndata, self.partitioner.min, self.partitioner.max) + elif self.uod_clip: ndata = np.clip(ndata, self.original_min, self.original_max) return ndata diff --git a/pyFTS/tests/multivariate.py b/pyFTS/tests/multivariate.py index 340dab8..4ceb69e 100644 --- a/pyFTS/tests/multivariate.py +++ b/pyFTS/tests/multivariate.py @@ -19,6 +19,24 @@ from pyFTS.common import Membership import os + +from pyFTS.data import NASDAQ + +train_data = NASDAQ.get_data()[:2000] +test_data = NASDAQ.get_data()[2000:3000] + +from pyFTS.partitioners import Grid + +partitioner = Grid.GridPartitioner(data=train_data, npart=35) + +from pyFTS.models import pwfts + +model = pwfts.ProbabilisticWeightedFTS(partitioner=partitioner, order=2) +model.train(train_data) + +print(model.predict(test_data[:100])) + + ''' def sample_by_hour(data): return [np.nanmean(data[k:k+60]) for k in np.arange(0,len(data),60)] @@ -43,7 +61,7 @@ var = { } df = pd.DataFrame(var) -''' + from pyFTS.data import Malaysia @@ -85,7 +103,7 @@ bchmk.multivariate_sliding_window_benchmarks2(df, 10000, train=0.9, inc=0.25, -''' + from pyFTS.data import lorentz df = lorentz.get_dataframe(iterations=5000)