CVFTS bugfixes

This commit is contained in:
Petrônio Cândido 2018-08-02 18:29:52 -03:00
parent f5652f7029
commit 9089310187
5 changed files with 21 additions and 25 deletions

View File

@ -280,8 +280,6 @@ def sliding_window_benchmarks(data, windowsize, train=0.8, **kwargs):
if progress:
progressbar.update(1)
try:
print(model.shortname, model.order, partitioner.name,
partitioner.partitions, str(partitioner.transformation))
job = experiment_method(deepcopy(model), deepcopy(partitioner), train, test, **kwargs)
synthesis_method(dataset, tag, job, conn)
except Exception as ex:

View File

@ -101,7 +101,7 @@ class ConditionalVarianceFTS(hofts.HighOrderFTS):
_range = (_max - _min)/2
translate = np.linspace(_min, _max, self.partitioner.partitions)
translate = np.linspace(_min, _max, len(self.partitioner.sets))
var = np.std(self.residuals)
@ -111,7 +111,7 @@ class ConditionalVarianceFTS(hofts.HighOrderFTS):
location = [_range + w + loc + k for k in np.linspace(-var,var) for w in translate]
perturb = [[location[k], var] for k in np.arange(0, self.partitioner.partitions)]
perturb = [[location[k], var] for k in np.arange(len(self.partitioner.sets))]
return perturb
@ -138,11 +138,14 @@ class ConditionalVarianceFTS(hofts.HighOrderFTS):
return perturb
def _fsset_key(self, ix):
return self.partitioner.ordered_sets[ix]
def _affected_sets(self, sample, perturb):
affected_sets = [[ct, self.sets[key].membership(sample, perturb[ct])]
for ct, key in enumerate(self.partitioner.ordered_sets)
if self.sets[key].membership(sample, perturb[ct]) > 0.0]
affected_sets = [[ct, self.sets[self._fsset_key(ct)].membership(sample, perturb[ct])]
for ct in np.arange(self.partitioner.partitions)
if self.sets[self._fsset_key(ct)].membership(sample, perturb[ct]) > 0.0]
if len(affected_sets) == 0:
if sample < self.partitioner.lower_set().get_lower(perturb[0]):
@ -167,7 +170,7 @@ class ConditionalVarianceFTS(hofts.HighOrderFTS):
if not no_update:
perturb = self.perturbation_factors(sample)
else:
perturb = [[0, 1] for k in np.arange(0, self.partitioner.partitions)]
perturb = [[0, 1] for k in np.arange(len(self.partitioner.sets))]
affected_sets = self._affected_sets(sample, perturb)

View File

@ -134,7 +134,6 @@ class SimpleNonStationaryPartitioner(partitioner.Partitioner):
return {}
def simplenonstationary_gridpartitioner_builder(data, npart, transformation):
from pyFTS.partitioners import Grid
from pyFTS.models.nonstationary import perturbation, partitioners

View File

@ -53,16 +53,10 @@ class Partitioner(object):
ndata[ndata == -np.inf] = 0
_min = np.nanmin(ndata)
if _min < 0:
self.min = _min * 1.1
else:
self.min = _min * 0.9
self.min = float(_min * 1.1 if _min < 0 else _min * 0.9)
_max = max(ndata)
if _max > 0:
self.max = _max * 1.1
else:
self.max = _max * 0.9
self.max = float(_max * 1.1 if _max > 0 else _max * 0.9)
self.sets = self.build(ndata)

View File

@ -11,17 +11,17 @@ import pandas as pd
from pyFTS.data import TAIEX, NASDAQ, SP500, artificial
datasets = {
"TAIEX": TAIEX.get_data()[:4000],
#"TAIEX": TAIEX.get_data()[:4000],
"SP500": SP500.get_data()[10000:14000],
"NASDAQ": NASDAQ.get_data()[:4000],
#"NASDAQ": NASDAQ.get_data()[:4000],
# Incremental Mean and Incremental Variance
"IMIV": artificial.generate_gaussian_linear(1,0.2,0.2,0.05,it=100, num=40),
#"IMIV": artificial.generate_gaussian_linear(1,0.2,0.2,0.05,it=100, num=40),
# Incremental Mean and Incremental Variance, lower bound equals to 0
"IMIV0": artificial.generate_gaussian_linear(1,0.2,0.,0.05, vmin=0,it=100, num=40),
#"IMIV0": artificial.generate_gaussian_linear(1,0.2,0.,0.05, vmin=0,it=100, num=40),
# Constant Mean and Incremental Variance
"CMIV": artificial.generate_gaussian_linear(5,0.1,0,0.02,it=100, num=40),
#"CMIV": artificial.generate_gaussian_linear(5,0.1,0,0.02,it=100, num=40),
# Incremental Mean and Constant Variance
"IMCV": artificial.generate_gaussian_linear(1,0.6,0.1,0,it=100, num=40)
#"IMCV": artificial.generate_gaussian_linear(1,0.6,0.1,0,it=100, num=40)
}
train_split = 2000
@ -34,9 +34,9 @@ tdiff = Transformations.Differential(1)
boxcox = Transformations.BoxCox(0)
transformations = {
'None': None,
#'None': None,
'Differential(1)': tdiff,
'BoxCox(0)': boxcox
#'BoxCox(0)': boxcox
}
from pyFTS.partitioners import Grid, Util as pUtil
@ -78,6 +78,8 @@ for ds in datasets.keys():
for ds in datasets.keys():
dataset = datasets[ds]
print(ds)
for tf in transformations.keys():
transformation = transformations[tf]