From 455ec33ee71b1a37d363ccbe839b31f0fc296efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Thu, 6 Dec 2018 14:38:34 -0200 Subject: [PATCH] Bugfix on pwfts --- pyFTS/common/FuzzySet.py | 2 +- pyFTS/models/multivariate/cmvfts.py | 2 +- pyFTS/tests/general.py | 2 +- pyFTS/tests/multivariate.py | 22 +++++++++++++++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pyFTS/common/FuzzySet.py b/pyFTS/common/FuzzySet.py index 617b519..43af285 100644 --- a/pyFTS/common/FuzzySet.py +++ b/pyFTS/common/FuzzySet.py @@ -141,7 +141,7 @@ def fuzzyfy(data, partitioner, **kwargs): if mode == 'vector': return fuzzyfy_instance(data, partitioner.sets, partitioner.ordered_sets) elif mode == 'both': - mv = fuzzyfy_instances(data, partitioner.sets, partitioner.ordered_sets) + mv = fuzzyfy_instance(data, partitioner.sets, partitioner.ordered_sets) fsets = [(partitioner.ordered_sets[ix], mv[ix]) for ix in np.arange(len(mv)) if mv[ix] >= alpha_cut] diff --git a/pyFTS/models/multivariate/cmvfts.py b/pyFTS/models/multivariate/cmvfts.py index bea237a..715033f 100644 --- a/pyFTS/models/multivariate/cmvfts.py +++ b/pyFTS/models/multivariate/cmvfts.py @@ -69,7 +69,7 @@ class ClusteredMVFTS(mvfts.MVFTS): if self.pre_fuzzyfy: ndata = self.fuzzyfy(ndata) else: - ndata = [self.format(k) for k in ndata.to_dict('records')] + ndata = [self.format_data(k) for k in ndata.to_dict('records')] return self.model.forecast(ndata, fuzzyfied=self.pre_fuzzyfy, **kwargs) diff --git a/pyFTS/tests/general.py b/pyFTS/tests/general.py index 78ea4df..8f55561 100644 --- a/pyFTS/tests/general.py +++ b/pyFTS/tests/general.py @@ -25,7 +25,7 @@ p = Grid.GridPartitioner(data=dataset, npart=20) print(p) -model = hofts.HighOrderFTS(partitioner=p, order=2) +model = pwfts.ProbabilisticWeightedFTS(partitioner=p, order=2) model.fit(dataset) #[22, 22, 23, 23, 24]) diff --git a/pyFTS/tests/multivariate.py b/pyFTS/tests/multivariate.py index aff0951..4dba416 100644 --- a/pyFTS/tests/multivariate.py +++ b/pyFTS/tests/multivariate.py @@ -18,6 +18,17 @@ from pyFTS.models.multivariate import common, variable, mvfts, cmvfts from pyFTS.models.seasonal import partitioner as seasonal from pyFTS.models.seasonal.common import DateTime +dataset = pd.read_csv('https://query.data.world/s/2bgegjggydd3venttp3zlosh3wpjqj', sep=';') + +dataset['data'] = pd.to_datetime(dataset["data"], format='%Y-%m-%d %H:%M:%S') + +data = dataset['glo_avg'].values + +train_mv = dataset.iloc[:24505] +test_mv = dataset.iloc[24505:] + + + ''' model = Util.load_obj('/home/petronio/Downloads/ClusteredMVFTS1solarorder2knn3') @@ -40,7 +51,7 @@ for ix, row in df.iterrows(): ''' # Multivariate time series - +''' dataset = pd.read_csv('https://query.data.world/s/2bgegjggydd3venttp3zlosh3wpjqj', sep=';') dataset['data'] = pd.to_datetime(dataset["data"], format='%Y-%m-%d %H:%M:%S') @@ -63,8 +74,17 @@ model.append_variable(vavg) model.target_variable = vavg model.fit(train_mv) +Util.persist_obj(model, model.shortname) +''' + +#model = Util.load_obj("ClusteredMVFTS") + +model = Util.load_obj("ClusteredMVFTS2loadorder2knn2") + print(model) +print(model.predict(test_mv)) + ''' train_mv = {} test_mv = {}