From 8e4b9b41211b7912c0f29edaeac6dafcd4fd578a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Tue, 21 May 2019 14:12:34 -0300 Subject: [PATCH] Bugfix on partitioner base class: the number of partitions is updated after the set construction --- pyFTS/partitioners/partitioner.py | 2 ++ pyFTS/tests/general.py | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/pyFTS/partitioners/partitioner.py b/pyFTS/partitioners/partitioner.py index 7672907..1f75b8b 100644 --- a/pyFTS/partitioners/partitioner.py +++ b/pyFTS/partitioners/partitioner.py @@ -67,6 +67,8 @@ class Partitioner(object): self.sets = self.build(ndata) + self.partitions = len(self.sets) + if self.ordered_sets is None and self.setnames is not None: self.ordered_sets = self.setnames[:len(self.sets)] else: diff --git a/pyFTS/tests/general.py b/pyFTS/tests/general.py index 7f4ef73..f50df95 100644 --- a/pyFTS/tests/general.py +++ b/pyFTS/tests/general.py @@ -18,19 +18,27 @@ from pyFTS.fcm import fts, common, GA from pyFTS.data import Enrollments, TAIEX -import pandas as pd -df = pd.read_csv('https://query.data.world/s/7zfy4d5uep7wbgf56k4uu5g52dmvap', sep=';') +x = [k for k in np.arange(-2*np.pi, 2*np.pi, 0.15)] +y = [np.sin(k) for k in x] -data = df['glo_avg'].values[:12000] +from pyFTS.models import hofts +from pyFTS.partitioners import Grid, FCM, CMeans, Entropy +from pyFTS.benchmarks import Measures -fs = Grid.GridPartitioner(data=data, npart=35, func=Membership.trimf) +metodos = [FCM.FCMPartitioner] +k = 35 -GA.parameters['num_concepts'] = 35 -GA.parameters['order'] = 2 -GA.parameters['partitioner'] = fs +rows = [] -GA.execute('TAIEX', data) +for contador, metodo in enumerate(metodos): + print(metodo) + part = metodo(data=y, npart=k) + model = hofts.HighOrderFTS(order=2, partitioner=part) + model.fit(y) + forecasts = model.predict(y) + for o in range(model.order): + forecasts.insert(0, None) '''