Bugfix on pwfts
This commit is contained in:
parent
819f8d3da1
commit
455ec33ee7
@ -141,7 +141,7 @@ def fuzzyfy(data, partitioner, **kwargs):
|
|||||||
if mode == 'vector':
|
if mode == 'vector':
|
||||||
return fuzzyfy_instance(data, partitioner.sets, partitioner.ordered_sets)
|
return fuzzyfy_instance(data, partitioner.sets, partitioner.ordered_sets)
|
||||||
elif mode == 'both':
|
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])
|
fsets = [(partitioner.ordered_sets[ix], mv[ix])
|
||||||
for ix in np.arange(len(mv))
|
for ix in np.arange(len(mv))
|
||||||
if mv[ix] >= alpha_cut]
|
if mv[ix] >= alpha_cut]
|
||||||
|
@ -69,7 +69,7 @@ class ClusteredMVFTS(mvfts.MVFTS):
|
|||||||
if self.pre_fuzzyfy:
|
if self.pre_fuzzyfy:
|
||||||
ndata = self.fuzzyfy(ndata)
|
ndata = self.fuzzyfy(ndata)
|
||||||
else:
|
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)
|
return self.model.forecast(ndata, fuzzyfied=self.pre_fuzzyfy, **kwargs)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ p = Grid.GridPartitioner(data=dataset, npart=20)
|
|||||||
|
|
||||||
print(p)
|
print(p)
|
||||||
|
|
||||||
model = hofts.HighOrderFTS(partitioner=p, order=2)
|
model = pwfts.ProbabilisticWeightedFTS(partitioner=p, order=2)
|
||||||
|
|
||||||
model.fit(dataset) #[22, 22, 23, 23, 24])
|
model.fit(dataset) #[22, 22, 23, 23, 24])
|
||||||
|
|
||||||
|
@ -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 import partitioner as seasonal
|
||||||
from pyFTS.models.seasonal.common import DateTime
|
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')
|
model = Util.load_obj('/home/petronio/Downloads/ClusteredMVFTS1solarorder2knn3')
|
||||||
|
|
||||||
@ -40,7 +51,7 @@ for ix, row in df.iterrows():
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
# Multivariate time series
|
# Multivariate time series
|
||||||
|
'''
|
||||||
dataset = pd.read_csv('https://query.data.world/s/2bgegjggydd3venttp3zlosh3wpjqj', sep=';')
|
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')
|
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.target_variable = vavg
|
||||||
model.fit(train_mv)
|
model.fit(train_mv)
|
||||||
|
|
||||||
|
Util.persist_obj(model, model.shortname)
|
||||||
|
'''
|
||||||
|
|
||||||
|
#model = Util.load_obj("ClusteredMVFTS")
|
||||||
|
|
||||||
|
model = Util.load_obj("ClusteredMVFTS2loadorder2knn2")
|
||||||
|
|
||||||
print(model)
|
print(model)
|
||||||
|
|
||||||
|
print(model.predict(test_mv))
|
||||||
|
|
||||||
'''
|
'''
|
||||||
train_mv = {}
|
train_mv = {}
|
||||||
test_mv = {}
|
test_mv = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user