Minor bugfixes on benchmarking methods

This commit is contained in:
Petrônio Cândido 2019-06-04 13:26:40 -03:00
parent f072d73d1b
commit 606c557214
5 changed files with 22 additions and 11 deletions

View File

@ -43,7 +43,7 @@ class ARIMA(fts.FTS):
self.order = self.p + self.q + (self.q - 1 if self.q > 0 else 0)
self.max_lag = self.order
self.d = len(self.transformations)
self.shortname = "ARIMA(" + str(self.p) + "," + str(self.d) + "," + str(self.q) + ") - " + str(self.alpha)
self.shortname = "BSTS({},{},{})-{}".format(self.p,self.d,self.q,self.alpha)
def train(self, data, **kwargs):

View File

@ -42,7 +42,7 @@ class ARIMA(fts.FTS):
self.order = self.p + self.q + (self.q - 1 if self.q > 0 else 0)
self.max_lag = self.order
self.d = len(self.transformations)
self.shortname = "ARIMA(" + str(self.p) + "," + str(self.d) + "," + str(self.q) + ") - " + str(self.alpha)
self.shortname = "ARIMA({},{},{})-{}".format(self.p, self.d, self.q, self.alpha)
def train(self, data, **kwargs):

View File

@ -61,6 +61,8 @@ class KNearestNeighbors(fts.FTS):
self.kdtree = KDTree(np.array(X))
self.values = Y
self.shortname = "kNN({})-{}".format(self.order, self.alpha)
def knn(self, sample):
X = self._prepare_x(sample)
_, ix = self.kdtree.query(np.array(X), self.k)

View File

@ -54,7 +54,7 @@ class QuantileRegression(fts.FTS):
up_qt = [k for k in uqt.params]
self.dist_qt.append([lo_qt, up_qt])
self.shortname = "QAR(" + str(self.order) + ") - " + str(self.alpha)
self.shortname = "QAR({})-{}".format(self.order,self.alpha)
def linearmodel(self,data,params):
#return params[0] + sum([ data[k] * params[k+1] for k in np.arange(0, self.order) ])

View File

@ -19,7 +19,7 @@ from pyFTS.fcm import fts, common, GA
from pyFTS.data import TAIEX, NASDAQ, SP500
#'''
'''
train = TAIEX.get_data()[:800]
test = TAIEX.get_data()[800:1000]
@ -52,13 +52,22 @@ datasets['TAIEX'] = TAIEX.get_data()[:5000]
datasets['NASDAQ'] = NASDAQ.get_data()[:5000]
datasets['SP500'] = SP500.get_data()[10000:15000]
methods = [arima.ARIMA, quantreg.QuantileRegression, BSTS.ARIMA, knn.KNearestNeighbors]
methods = [
arima.ARIMA,arima.ARIMA,
quantreg.QuantileRegression,quantreg.QuantileRegression,
BSTS.ARIMA,BSTS.ARIMA,
knn.KNearestNeighbors,knn.KNearestNeighbors
]
methods_parameters = [
{'order':(2,0,0)},
{'order':2, 'dist': True},
{'order':(2,0,0)},
{'order':2 }
{'order':(2,0,0), 'alpha':.05},
{'order':(2,0,0), 'alpha':.25},
{'order':2, 'alpha':.05},
{'order':2, 'alpha':.25},
{'order': (2, 0, 0), 'alpha': .05},
{'order': (2, 0, 0), 'alpha': .25},
{'order': 2, 'alpha': .05},
{'order': 2, 'alpha': .25}
]
for dataset_name, dataset in datasets.items():
@ -72,8 +81,8 @@ for dataset_name, dataset in datasets.items():
orders=[],
steps_ahead=[10],
partitions=[],
type='distribution',
type='interval',
distributed=True, nodes=['192.168.0.110', '192.168.0.107','192.168.0.106'],
file="experiments.db", dataset=dataset_name, tag="experiments")
# file="tmp.db", dataset='TAIEX', tag="experiments")
'''
#'''