Bugfix on pwfts

This commit is contained in:
Petrônio Cândido 2018-12-06 14:38:34 -02:00
parent 819f8d3da1
commit 455ec33ee7
4 changed files with 24 additions and 4 deletions

View File

@ -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]

View File

@ -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)

View File

@ -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])

View File

@ -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 = {}