- Several bugfixes
- Issue #2 - PEP 8 compliance - Issue #3 - Code documentation with PEP 257 compliance
This commit is contained in:
parent
a4903fd932
commit
18e795bcd3
@ -205,12 +205,12 @@ def get_point_statistics(data, model, indexer=None):
|
|||||||
else:
|
else:
|
||||||
ndata = np.array(data[model.order:])
|
ndata = np.array(data[model.order:])
|
||||||
|
|
||||||
if model.isMultivariate or indexer is None:
|
if model.is_multivariate or indexer is None:
|
||||||
forecasts = model.forecast(data)
|
forecasts = model.forecast(data)
|
||||||
elif not model.isMultivariate and indexer is not None:
|
elif not model.is_multivariate and indexer is not None:
|
||||||
forecasts = model.forecast(indexer.get_data(data))
|
forecasts = model.forecast(indexer.get_data(data))
|
||||||
|
|
||||||
if model.hasSeasonality:
|
if model.has_seasonality:
|
||||||
nforecasts = np.array(forecasts)
|
nforecasts = np.array(forecasts)
|
||||||
else:
|
else:
|
||||||
nforecasts = np.array(forecasts[:-1])
|
nforecasts = np.array(forecasts[:-1])
|
||||||
|
@ -122,7 +122,7 @@ def point_sliding_window(data, windowsize, train=0.8,models=None,partitioners=[G
|
|||||||
_key = mfts.shortname + " " + pttr + " q = " + str(partition)
|
_key = mfts.shortname + " " + pttr + " q = " + str(partition)
|
||||||
|
|
||||||
mfts.partitioner = data_train_fs
|
mfts.partitioner = data_train_fs
|
||||||
if not mfts.isHighOrder:
|
if not mfts.is_high_order:
|
||||||
|
|
||||||
if dump: print(ct,_key)
|
if dump: print(ct,_key)
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ def point_sliding_window(data, windowsize, train=0.8,models=None,partitioners=[G
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
for order in np.arange(1, max_order + 1):
|
for order in np.arange(1, max_order + 1):
|
||||||
if order >= mfts.minOrder:
|
if order >= mfts.min_order:
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
|
|
||||||
_key = mfts.shortname + " n = " + str(order) + " " + pttr + " q = " + str(partition)
|
_key = mfts.shortname + " n = " + str(order) + " " + pttr + " q = " + str(partition)
|
||||||
@ -225,7 +225,7 @@ def all_point_forecasters(data_train, data_test, partitions, max_order=3, statis
|
|||||||
for count, model in enumerate(models, start=0):
|
for count, model in enumerate(models, start=0):
|
||||||
#print(model)
|
#print(model)
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
if not mfts.isHighOrder:
|
if not mfts.is_high_order:
|
||||||
if transformation is not None:
|
if transformation is not None:
|
||||||
mfts.appendTransformation(transformation)
|
mfts.appendTransformation(transformation)
|
||||||
mfts.train(data_train, data_train_fs.sets)
|
mfts.train(data_train, data_train_fs.sets)
|
||||||
@ -233,7 +233,7 @@ def all_point_forecasters(data_train, data_test, partitions, max_order=3, statis
|
|||||||
lcolors.append( colors[count % ncol] )
|
lcolors.append( colors[count % ncol] )
|
||||||
else:
|
else:
|
||||||
for order in np.arange(1,max_order+1):
|
for order in np.arange(1,max_order+1):
|
||||||
if order >= mfts.minOrder:
|
if order >= mfts.min_order:
|
||||||
mfts = model(" n = " + str(order))
|
mfts = model(" n = " + str(order))
|
||||||
if transformation is not None:
|
if transformation is not None:
|
||||||
mfts.appendTransformation(transformation)
|
mfts.appendTransformation(transformation)
|
||||||
@ -387,7 +387,7 @@ def interval_sliding_window(data, windowsize, train=0.8,models=None,partitioners
|
|||||||
_key = mfts.shortname + " " + pttr+ " q = " +str(partition)
|
_key = mfts.shortname + " " + pttr+ " q = " +str(partition)
|
||||||
|
|
||||||
mfts.partitioner = data_train_fs
|
mfts.partitioner = data_train_fs
|
||||||
if not mfts.isHighOrder:
|
if not mfts.is_high_order:
|
||||||
|
|
||||||
if dump: print(ct,_key)
|
if dump: print(ct,_key)
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ def interval_sliding_window(data, windowsize, train=0.8,models=None,partitioners
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
for order in np.arange(1, max_order + 1):
|
for order in np.arange(1, max_order + 1):
|
||||||
if order >= mfts.minOrder:
|
if order >= mfts.min_order:
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
_key = mfts.shortname + " n = " + str(order) + " " + pttr + " q = " + str(partition)
|
_key = mfts.shortname + " n = " + str(order) + " " + pttr + " q = " + str(partition)
|
||||||
mfts.partitioner = data_train_fs
|
mfts.partitioner = data_train_fs
|
||||||
@ -467,7 +467,7 @@ def all_interval_forecasters(data_train, data_test, partitions, max_order=3,save
|
|||||||
|
|
||||||
for count, model in Util.enumerate2(models, start=0, step=2):
|
for count, model in Util.enumerate2(models, start=0, step=2):
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
if not mfts.isHighOrder:
|
if not mfts.is_high_order:
|
||||||
if transformation is not None:
|
if transformation is not None:
|
||||||
mfts.appendTransformation(transformation)
|
mfts.appendTransformation(transformation)
|
||||||
mfts.train(data_train, data_train_fs)
|
mfts.train(data_train, data_train_fs)
|
||||||
@ -475,7 +475,7 @@ def all_interval_forecasters(data_train, data_test, partitions, max_order=3,save
|
|||||||
lcolors.append( colors[count % ncol] )
|
lcolors.append( colors[count % ncol] )
|
||||||
else:
|
else:
|
||||||
for order in np.arange(1,max_order+1):
|
for order in np.arange(1,max_order+1):
|
||||||
if order >= mfts.minOrder:
|
if order >= mfts.min_order:
|
||||||
mfts = model(" n = " + str(order))
|
mfts = model(" n = " + str(order))
|
||||||
if transformation is not None:
|
if transformation is not None:
|
||||||
mfts.appendTransformation(transformation)
|
mfts.appendTransformation(transformation)
|
||||||
@ -522,7 +522,7 @@ def plot_compared_series(original, models, colors, typeonlegend=False, save=Fals
|
|||||||
ax.plot(original, color='black', label="Original", linewidth=linewidth*1.5)
|
ax.plot(original, color='black', label="Original", linewidth=linewidth*1.5)
|
||||||
|
|
||||||
for count, fts in enumerate(models, start=0):
|
for count, fts in enumerate(models, start=0):
|
||||||
if fts.hasPointForecasting and points:
|
if fts.has_point_forecasting and points:
|
||||||
forecasted = fts.forecast(original)
|
forecasted = fts.forecast(original)
|
||||||
mi.append(min(forecasted) * 0.95)
|
mi.append(min(forecasted) * 0.95)
|
||||||
ma.append(max(forecasted) * 1.05)
|
ma.append(max(forecasted) * 1.05)
|
||||||
@ -532,7 +532,7 @@ def plot_compared_series(original, models, colors, typeonlegend=False, save=Fals
|
|||||||
if typeonlegend: lbl += " (Point)"
|
if typeonlegend: lbl += " (Point)"
|
||||||
ax.plot(forecasted, color=colors[count], label=lbl, ls="-",linewidth=linewidth)
|
ax.plot(forecasted, color=colors[count], label=lbl, ls="-",linewidth=linewidth)
|
||||||
|
|
||||||
if fts.hasIntervalForecasting and intervals:
|
if fts.has_interval_forecasting and intervals:
|
||||||
forecasted = fts.forecastInterval(original)
|
forecasted = fts.forecastInterval(original)
|
||||||
lower = [kk[0] for kk in forecasted]
|
lower = [kk[0] for kk in forecasted]
|
||||||
upper = [kk[1] for kk in forecasted]
|
upper = [kk[1] for kk in forecasted]
|
||||||
@ -660,7 +660,7 @@ def ahead_sliding_window(data, windowsize, train, steps, models=None, resolution
|
|||||||
_key = mfts.shortname + " " + pttr+ " q = " +str(partition)
|
_key = mfts.shortname + " " + pttr+ " q = " +str(partition)
|
||||||
|
|
||||||
mfts.partitioner = data_train_fs
|
mfts.partitioner = data_train_fs
|
||||||
if not mfts.isHighOrder:
|
if not mfts.is_high_order:
|
||||||
|
|
||||||
if dump: print(ct,_key)
|
if dump: print(ct,_key)
|
||||||
|
|
||||||
@ -692,7 +692,7 @@ def ahead_sliding_window(data, windowsize, train, steps, models=None, resolution
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
for order in np.arange(1, max_order + 1):
|
for order in np.arange(1, max_order + 1):
|
||||||
if order >= mfts.minOrder:
|
if order >= mfts.min_order:
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
_key = mfts.shortname + " n = " + str(order) + " " + pttr + " q = " + str(partition)
|
_key = mfts.shortname + " n = " + str(order) + " " + pttr + " q = " + str(partition)
|
||||||
mfts.partitioner = data_train_fs
|
mfts.partitioner = data_train_fs
|
||||||
@ -743,7 +743,7 @@ def all_ahead_forecasters(data_train, data_test, partitions, start, steps, resol
|
|||||||
|
|
||||||
for count, model in Util.enumerate2(models, start=0, step=2):
|
for count, model in Util.enumerate2(models, start=0, step=2):
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
if not mfts.isHighOrder:
|
if not mfts.is_high_order:
|
||||||
if transformation is not None:
|
if transformation is not None:
|
||||||
mfts.appendTransformation(transformation)
|
mfts.appendTransformation(transformation)
|
||||||
mfts.train(data_train, data_train_fs)
|
mfts.train(data_train, data_train_fs)
|
||||||
@ -751,7 +751,7 @@ def all_ahead_forecasters(data_train, data_test, partitions, start, steps, resol
|
|||||||
lcolors.append( colors[count % ncol] )
|
lcolors.append( colors[count % ncol] )
|
||||||
else:
|
else:
|
||||||
for order in np.arange(1,max_order+1):
|
for order in np.arange(1,max_order+1):
|
||||||
if order >= mfts.minOrder:
|
if order >= mfts.min_order:
|
||||||
mfts = model(" n = " + str(order))
|
mfts = model(" n = " + str(order))
|
||||||
if transformation is not None:
|
if transformation is not None:
|
||||||
mfts.appendTransformation(transformation)
|
mfts.appendTransformation(transformation)
|
||||||
@ -822,7 +822,7 @@ def plot_compared_intervals_ahead(original, models, colors, distributions, time_
|
|||||||
ma = []
|
ma = []
|
||||||
|
|
||||||
for count, fts in enumerate(models, start=0):
|
for count, fts in enumerate(models, start=0):
|
||||||
if fts.hasDistributionForecasting and distributions[count]:
|
if fts.has_probability_forecasting and distributions[count]:
|
||||||
density = fts.forecastAheadDistribution(original[time_from - fts.order:time_from], time_to,
|
density = fts.forecastAheadDistribution(original[time_from - fts.order:time_from], time_to,
|
||||||
resolution=resolution, method=option)
|
resolution=resolution, method=option)
|
||||||
|
|
||||||
@ -863,7 +863,7 @@ def plot_compared_intervals_ahead(original, models, colors, distributions, time_
|
|||||||
cb.set_label('Density')
|
cb.set_label('Density')
|
||||||
|
|
||||||
|
|
||||||
if fts.hasIntervalForecasting:
|
if fts.has_interval_forecasting:
|
||||||
forecasts = fts.forecastAheadInterval(original[time_from - fts.order:time_from], time_to)
|
forecasts = fts.forecastAheadInterval(original[time_from - fts.order:time_from], time_to)
|
||||||
lower = [kk[0] for kk in forecasts]
|
lower = [kk[0] for kk in forecasts]
|
||||||
upper = [kk[1] for kk in forecasts]
|
upper = [kk[1] for kk in forecasts]
|
||||||
@ -939,7 +939,7 @@ def SelecaoSimples_MenorRMSE(original, parameters, modelo):
|
|||||||
min_rmse = 100000.0
|
min_rmse = 100000.0
|
||||||
best = None
|
best = None
|
||||||
for p in parameters:
|
for p in parameters:
|
||||||
sets = Grid.GridPartitionerTrimf(original, p)
|
sets = Grid.GridPartitioner(original, p).sets
|
||||||
fts = modelo(str(p) + " particoes")
|
fts = modelo(str(p) + " particoes")
|
||||||
fts.train(original, sets)
|
fts.train(original, sets)
|
||||||
# print(original)
|
# print(original)
|
||||||
@ -1095,7 +1095,7 @@ def simpleSearch_RMSE(train, test, model, partitions, orders, save=False, file=N
|
|||||||
fts.train(train, sets, o, parameters=parameters)
|
fts.train(train, sets, o, parameters=parameters)
|
||||||
if not intervals:
|
if not intervals:
|
||||||
forecasted = fts.forecast(test)
|
forecasted = fts.forecast(test)
|
||||||
if not fts.hasSeasonality:
|
if not fts.has_seasonality:
|
||||||
error = Measures.rmse(np.array(test[o:]), np.array(forecasted[:-1]))
|
error = Measures.rmse(np.array(test[o:]), np.array(forecasted[:-1]))
|
||||||
else:
|
else:
|
||||||
error = Measures.rmse(np.array(test[o:]), np.array(forecasted))
|
error = Measures.rmse(np.array(test[o:]), np.array(forecasted))
|
||||||
@ -1171,7 +1171,7 @@ def sliding_window_simple_search(data, windowsize, model, partitions, orders, sa
|
|||||||
fts.train(data, sets, o, parameters=parameters)
|
fts.train(data, sets, o, parameters=parameters)
|
||||||
if not intervals:
|
if not intervals:
|
||||||
forecasted = fts.forecast(test)
|
forecasted = fts.forecast(test)
|
||||||
if not fts.hasSeasonality:
|
if not fts.has_seasonality:
|
||||||
_error.append( Measures.rmse(np.array(test[o:]), np.array(forecasted[:-1])) )
|
_error.append( Measures.rmse(np.array(test[o:]), np.array(forecasted[:-1])) )
|
||||||
else:
|
else:
|
||||||
_error.append( Measures.rmse(np.array(test[o:]), np.array(forecasted)) )
|
_error.append( Measures.rmse(np.array(test[o:]), np.array(forecasted)) )
|
||||||
@ -1221,7 +1221,7 @@ def sliding_window_simple_search(data, windowsize, model, partitions, orders, sa
|
|||||||
|
|
||||||
def pftsExploreOrderAndPartitions(data,save=False, file=None):
|
def pftsExploreOrderAndPartitions(data,save=False, file=None):
|
||||||
fig, axes = plt.subplots(nrows=4, ncols=1, figsize=[6, 8])
|
fig, axes = plt.subplots(nrows=4, ncols=1, figsize=[6, 8])
|
||||||
data_fs1 = Grid.GridPartitionerTrimf(data, 10)
|
data_fs1 = Grid.GridPartitioner(data, 10).sets
|
||||||
mi = []
|
mi = []
|
||||||
ma = []
|
ma = []
|
||||||
|
|
||||||
@ -1250,7 +1250,7 @@ def pftsExploreOrderAndPartitions(data,save=False, file=None):
|
|||||||
axes[3].set_title('Interval Forecasts by Number of Partitions')
|
axes[3].set_title('Interval Forecasts by Number of Partitions')
|
||||||
|
|
||||||
for partitions in np.arange(5, 11):
|
for partitions in np.arange(5, 11):
|
||||||
data_fs = Grid.GridPartitionerTrimf(data, partitions)
|
data_fs = Grid.GridPartitioner(data, partitions).sets
|
||||||
fts = pwfts.ProbabilisticWeightedFTS("")
|
fts = pwfts.ProbabilisticWeightedFTS("")
|
||||||
fts.shortname = "q = " + str(partitions)
|
fts.shortname = "q = " + str(partitions)
|
||||||
fts.train(data, data_fs, 1)
|
fts.train(data, data_fs, 1)
|
||||||
|
@ -74,9 +74,9 @@ def point_sliding_window(data, windowsize, train=0.8, models=None, partitioners=
|
|||||||
for model in models:
|
for model in models:
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
|
|
||||||
if mfts.isHighOrder:
|
if mfts.is_high_order:
|
||||||
for order in np.arange(1, max_order + 1):
|
for order in np.arange(1, max_order + 1):
|
||||||
if order >= mfts.minOrder:
|
if order >= mfts.min_order:
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
mfts.order = order
|
mfts.order = order
|
||||||
pool.append(mfts)
|
pool.append(mfts)
|
||||||
@ -193,9 +193,9 @@ def interval_sliding_window(data, windowsize, train=0.8, models=None, partitione
|
|||||||
for model in models:
|
for model in models:
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
|
|
||||||
if mfts.isHighOrder:
|
if mfts.is_high_order:
|
||||||
for order in np.arange(1, max_order + 1):
|
for order in np.arange(1, max_order + 1):
|
||||||
if order >= mfts.minOrder:
|
if order >= mfts.min_order:
|
||||||
mfts = model("")
|
mfts = model("")
|
||||||
mfts.order = order
|
mfts.order = order
|
||||||
pool.append(mfts)
|
pool.append(mfts)
|
||||||
|
2
chen.py
2
chen.py
@ -25,7 +25,7 @@ class ConventionalFLRG(object):
|
|||||||
|
|
||||||
|
|
||||||
class ConventionalFTS(fts.FTS):
|
class ConventionalFTS(fts.FTS):
|
||||||
def __init__(self, order, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(ConventionalFTS, self).__init__(1, "CFTS " + name)
|
super(ConventionalFTS, self).__init__(1, "CFTS " + name)
|
||||||
self.name = "Conventional FTS"
|
self.name = "Conventional FTS"
|
||||||
self.detail = "Chen"
|
self.detail = "Chen"
|
||||||
|
2
cheng.py
2
cheng.py
@ -31,7 +31,7 @@ class TrendWeightedFLRG(yu.WeightedFTS):
|
|||||||
|
|
||||||
|
|
||||||
class TrendWeightedFTS(yu.WeightedFTS):
|
class TrendWeightedFTS(yu.WeightedFTS):
|
||||||
def __init__(self, order, name, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(TrendWeightedFTS, self).__init__(1, "TWFTS " + name)
|
super(TrendWeightedFTS, self).__init__(1, "TWFTS " + name)
|
||||||
self.name = "Trend Weighted FTS"
|
self.name = "Trend Weighted FTS"
|
||||||
self.detail = "Cheng"
|
self.detail = "Cheng"
|
||||||
|
@ -10,7 +10,7 @@ from pyFTS import fts
|
|||||||
|
|
||||||
|
|
||||||
class EnsembleFTS(fts.FTS):
|
class EnsembleFTS(fts.FTS):
|
||||||
def __init__(self, order, name, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(EnsembleFTS, self).__init__("Ensemble FTS")
|
super(EnsembleFTS, self).__init__("Ensemble FTS")
|
||||||
self.shortname = "Ensemble FTS " + name
|
self.shortname = "Ensemble FTS " + name
|
||||||
self.name = "Ensemble FTS"
|
self.name = "Ensemble FTS"
|
||||||
|
2
hofts.py
2
hofts.py
@ -39,7 +39,7 @@ class HighOrderFLRG(object):
|
|||||||
|
|
||||||
|
|
||||||
class HighOrderFTS(fts.FTS):
|
class HighOrderFTS(fts.FTS):
|
||||||
def __init__(self, order, name, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(HighOrderFTS, self).__init__(1, "HOFTS" + name)
|
super(HighOrderFTS, self).__init__(1, "HOFTS" + name)
|
||||||
self.name = "High Order FTS"
|
self.name = "High Order FTS"
|
||||||
self.shortname = "HOFTS" + name
|
self.shortname = "HOFTS" + name
|
||||||
|
2
hwang.py
2
hwang.py
@ -4,7 +4,7 @@ from pyFTS import fts
|
|||||||
|
|
||||||
|
|
||||||
class HighOrderFTS(fts.FTS):
|
class HighOrderFTS(fts.FTS):
|
||||||
def __init__(self, order, name, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(HighOrderFTS, self).__init__(1, name)
|
super(HighOrderFTS, self).__init__(1, name)
|
||||||
self.is_high_order = True
|
self.is_high_order = True
|
||||||
self.min_order = 2
|
self.min_order = 2
|
||||||
|
2
ifts.py
2
ifts.py
@ -7,7 +7,7 @@ from pyFTS import hofts, fts, tree
|
|||||||
|
|
||||||
|
|
||||||
class IntervalFTS(hofts.HighOrderFTS):
|
class IntervalFTS(hofts.HighOrderFTS):
|
||||||
def __init__(self, order, name, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(IntervalFTS, self).__init__(order=1, name="IFTS " + name)
|
super(IntervalFTS, self).__init__(order=1, name="IFTS " + name)
|
||||||
self.shortname = "IFTS " + name
|
self.shortname = "IFTS " + name
|
||||||
self.name = "Interval FTS"
|
self.name = "Interval FTS"
|
||||||
|
@ -33,7 +33,7 @@ class ImprovedWeightedFLRG(object):
|
|||||||
|
|
||||||
|
|
||||||
class ImprovedWeightedFTS(fts.FTS):
|
class ImprovedWeightedFTS(fts.FTS):
|
||||||
def __init__(self, order, name, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(ImprovedWeightedFTS, self).__init__(1, "IWFTS " + name)
|
super(ImprovedWeightedFTS, self).__init__(1, "IWFTS " + name)
|
||||||
self.name = "Improved Weighted FTS"
|
self.name = "Improved Weighted FTS"
|
||||||
self.detail = "Ismail & Efendi"
|
self.detail = "Ismail & Efendi"
|
||||||
|
@ -37,7 +37,7 @@ class ExponentialyWeightedFLRG(object):
|
|||||||
|
|
||||||
|
|
||||||
class ExponentialyWeightedFTS(fts.FTS):
|
class ExponentialyWeightedFTS(fts.FTS):
|
||||||
def __init__(self, order, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(ExponentialyWeightedFTS, self).__init__(1, "EWFTS")
|
super(ExponentialyWeightedFTS, self).__init__(1, "EWFTS")
|
||||||
self.name = "Exponentialy Weighted FTS"
|
self.name = "Exponentialy Weighted FTS"
|
||||||
self.detail = "Sadaei"
|
self.detail = "Sadaei"
|
||||||
|
2
sfts.py
2
sfts.py
@ -26,7 +26,7 @@ class SeasonalFLRG(FLR.FLR):
|
|||||||
|
|
||||||
|
|
||||||
class SeasonalFTS(fts.FTS):
|
class SeasonalFTS(fts.FTS):
|
||||||
def __init__(self, order, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(SeasonalFTS, self).__init__(1, "SFTS")
|
super(SeasonalFTS, self).__init__(1, "SFTS")
|
||||||
self.name = "Seasonal FTS"
|
self.name = "Seasonal FTS"
|
||||||
self.detail = "Chen"
|
self.detail = "Chen"
|
||||||
|
@ -12,14 +12,14 @@ import pandas as pd
|
|||||||
from pyFTS.partitioners import Grid, Entropy, FCM, Huarng
|
from pyFTS.partitioners import Grid, Entropy, FCM, Huarng
|
||||||
from pyFTS.common import FLR,FuzzySet,Membership,Transformations
|
from pyFTS.common import FLR,FuzzySet,Membership,Transformations
|
||||||
from pyFTS import fts,hofts,ifts,pwfts,tree, chen
|
from pyFTS import fts,hofts,ifts,pwfts,tree, chen
|
||||||
from pyFTS.benchmarks import benchmarks as bchmk
|
#from pyFTS.benchmarks import benchmarks as bchmk
|
||||||
from pyFTS.benchmarks import naive, arima
|
from pyFTS.benchmarks import naive, arima
|
||||||
from pyFTS.benchmarks import Measures
|
from pyFTS.benchmarks import Measures
|
||||||
from numpy import random
|
from numpy import random
|
||||||
|
|
||||||
#print(FCM.FCMPartitionerTrimf.__module__)
|
#print(FCM.FCMPartitionerTrimf.__module__)
|
||||||
|
|
||||||
#gauss = random.normal(0,1.0,5000)
|
#gauss = random.normal(0,1.0,1000)
|
||||||
#gauss_teste = random.normal(0,1.0,400)
|
#gauss_teste = random.normal(0,1.0,400)
|
||||||
|
|
||||||
|
|
||||||
@ -31,14 +31,14 @@ taiex = np.array(taiexpd["avg"][:5000])
|
|||||||
#from statsmodels.tsa.arima_model import ARIMA as stats_arima
|
#from statsmodels.tsa.arima_model import ARIMA as stats_arima
|
||||||
from statsmodels.tsa.tsatools import lagmat
|
from statsmodels.tsa.tsatools import lagmat
|
||||||
|
|
||||||
tmp = np.arange(10)
|
#tmp = np.arange(10)
|
||||||
|
|
||||||
lag, a = lagmat(tmp, maxlag=2, trim="both", original='sep')
|
#lag, a = lagmat(tmp, maxlag=2, trim="both", original='sep')
|
||||||
|
|
||||||
print(lag)
|
#print(lag)
|
||||||
print(a)
|
#print(a)
|
||||||
|
|
||||||
#from pyFTS.benchmarks import distributed_benchmarks as bchmk
|
from pyFTS.benchmarks import distributed_benchmarks as bchmk
|
||||||
#from pyFTS.benchmarks import parallel_benchmarks as bchmk
|
#from pyFTS.benchmarks import parallel_benchmarks as bchmk
|
||||||
#from pyFTS.benchmarks import benchmarks as bchmk
|
#from pyFTS.benchmarks import benchmarks as bchmk
|
||||||
#from pyFTS.benchmarks import arima
|
#from pyFTS.benchmarks import arima
|
||||||
@ -52,11 +52,11 @@ print(a)
|
|||||||
|
|
||||||
#bchmk.teste(taiex,['192.168.0.109', '192.168.0.101'])
|
#bchmk.teste(taiex,['192.168.0.109', '192.168.0.101'])
|
||||||
|
|
||||||
#bchmk.point_sliding_window(taiex,2000,train=0.8, #models=[yu.WeightedFTS], # #
|
bchmk.point_sliding_window(taiex,2000,train=0.8, #models=[yu.WeightedFTS], # #
|
||||||
# partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
||||||
# partitions= np.arange(10,200,step=5), #transformation=diff,
|
partitions= np.arange(10,200,step=5), #transformation=diff,
|
||||||
# dump=False, save=True, file="experiments/nasdaq_point_distributed.csv",
|
dump=False, save=False, file="experiments/nasdaq_point_distributed.csv",
|
||||||
# nodes=['192.168.0.109', '192.168.0.101']) #, depends=[hofts, ifts])
|
nodes=['192.168.1.42']) #, depends=[hofts, ifts])
|
||||||
|
|
||||||
#bchmk.testa(taiex,[10,20],partitioners=[Grid.GridPartitioner], nodes=['192.168.0.109', '192.168.0.101'])
|
#bchmk.testa(taiex,[10,20],partitioners=[Grid.GridPartitioner], nodes=['192.168.0.109', '192.168.0.101'])
|
||||||
|
|
||||||
@ -83,10 +83,10 @@ print(a)
|
|||||||
# gauss,2000,train=0.8, dump=True, save=True, file="experiments/arima_gauss.csv")
|
# gauss,2000,train=0.8, dump=True, save=True, file="experiments/arima_gauss.csv")
|
||||||
|
|
||||||
|
|
||||||
#bchmk.interval_sliding_window(nasdaq,2000,train=0.8, #transformation=diff, #models=[pwfts.ProbabilisticWeightedFTS], # #
|
bchmk.interval_sliding_window(gauss,2000,train=0.8, #transformation=diff, #models=[pwfts.ProbabilisticWeightedFTS], # #
|
||||||
# partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
||||||
# partitions= np.arange(10,200,step=5), #
|
partitions= np.arange(10,200,step=5), #
|
||||||
# dump=True, save=True, file="experiments/nasdaq_interval.csv")
|
dump=True, save=False, file="experiments/nasdaq_interval.csv")
|
||||||
|
|
||||||
#3bchmk.ahead_sliding_window(taiex,2000,train=0.8, steps=20, resolution=250, #transformation=diff, #models=[pwfts.ProbabilisticWeightedFTS], # #
|
#3bchmk.ahead_sliding_window(taiex,2000,train=0.8, steps=20, resolution=250, #transformation=diff, #models=[pwfts.ProbabilisticWeightedFTS], # #
|
||||||
# partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
# partitioners=[Grid.GridPartitioner], #Entropy.EntropyPartitioner], # FCM.FCMPartitioner, ],
|
||||||
|
@ -53,8 +53,8 @@ pfts3_enrollments.train(enrollments, enrollments_fs1, 3)
|
|||||||
|
|
||||||
bchmk.plot_compared_series(enrollments,[pfts1_enrollments,pfts2_enrollments, pfts3_enrollments],
|
bchmk.plot_compared_series(enrollments,[pfts1_enrollments,pfts2_enrollments, pfts3_enrollments],
|
||||||
["red","blue","green"], linewidth=2,
|
["red","blue","green"], linewidth=2,
|
||||||
typeonlegend=True,save=True,file="pictures/pwfts_enrollments_interval.png",
|
typeonlegend=True,save=False,file="pictures/pwfts_enrollments_interval.png",
|
||||||
tam=[20,7],points=False, intervals=False)
|
tam=[20,7],points=False, intervals=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2
yu.py
2
yu.py
@ -31,7 +31,7 @@ class WeightedFLRG(fts.FTS):
|
|||||||
|
|
||||||
|
|
||||||
class WeightedFTS(fts.FTS):
|
class WeightedFTS(fts.FTS):
|
||||||
def __init__(self, order, name, **kwargs):
|
def __init__(self, name, **kwargs):
|
||||||
super(WeightedFTS, self).__init__(1, "WFTS " + name)
|
super(WeightedFTS, self).__init__(1, "WFTS " + name)
|
||||||
self.name = "Weighted FTS"
|
self.name = "Weighted FTS"
|
||||||
self.detail = "Yu"
|
self.detail = "Yu"
|
||||||
|
Loading…
Reference in New Issue
Block a user