CVFTS bugfixes
This commit is contained in:
parent
f5652f7029
commit
9089310187
@ -280,8 +280,6 @@ def sliding_window_benchmarks(data, windowsize, train=0.8, **kwargs):
|
|||||||
if progress:
|
if progress:
|
||||||
progressbar.update(1)
|
progressbar.update(1)
|
||||||
try:
|
try:
|
||||||
print(model.shortname, model.order, partitioner.name,
|
|
||||||
partitioner.partitions, str(partitioner.transformation))
|
|
||||||
job = experiment_method(deepcopy(model), deepcopy(partitioner), train, test, **kwargs)
|
job = experiment_method(deepcopy(model), deepcopy(partitioner), train, test, **kwargs)
|
||||||
synthesis_method(dataset, tag, job, conn)
|
synthesis_method(dataset, tag, job, conn)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
@ -101,7 +101,7 @@ class ConditionalVarianceFTS(hofts.HighOrderFTS):
|
|||||||
|
|
||||||
_range = (_max - _min)/2
|
_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)
|
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]
|
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
|
return perturb
|
||||||
|
|
||||||
@ -138,11 +138,14 @@ class ConditionalVarianceFTS(hofts.HighOrderFTS):
|
|||||||
|
|
||||||
return perturb
|
return perturb
|
||||||
|
|
||||||
|
def _fsset_key(self, ix):
|
||||||
|
return self.partitioner.ordered_sets[ix]
|
||||||
|
|
||||||
def _affected_sets(self, sample, perturb):
|
def _affected_sets(self, sample, perturb):
|
||||||
|
|
||||||
affected_sets = [[ct, self.sets[key].membership(sample, perturb[ct])]
|
affected_sets = [[ct, self.sets[self._fsset_key(ct)].membership(sample, perturb[ct])]
|
||||||
for ct, key in enumerate(self.partitioner.ordered_sets)
|
for ct in np.arange(self.partitioner.partitions)
|
||||||
if self.sets[key].membership(sample, perturb[ct]) > 0.0]
|
if self.sets[self._fsset_key(ct)].membership(sample, perturb[ct]) > 0.0]
|
||||||
|
|
||||||
if len(affected_sets) == 0:
|
if len(affected_sets) == 0:
|
||||||
if sample < self.partitioner.lower_set().get_lower(perturb[0]):
|
if sample < self.partitioner.lower_set().get_lower(perturb[0]):
|
||||||
@ -167,7 +170,7 @@ class ConditionalVarianceFTS(hofts.HighOrderFTS):
|
|||||||
if not no_update:
|
if not no_update:
|
||||||
perturb = self.perturbation_factors(sample)
|
perturb = self.perturbation_factors(sample)
|
||||||
else:
|
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)
|
affected_sets = self._affected_sets(sample, perturb)
|
||||||
|
|
||||||
|
@ -134,7 +134,6 @@ class SimpleNonStationaryPartitioner(partitioner.Partitioner):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def simplenonstationary_gridpartitioner_builder(data, npart, transformation):
|
def simplenonstationary_gridpartitioner_builder(data, npart, transformation):
|
||||||
from pyFTS.partitioners import Grid
|
from pyFTS.partitioners import Grid
|
||||||
from pyFTS.models.nonstationary import perturbation, partitioners
|
from pyFTS.models.nonstationary import perturbation, partitioners
|
||||||
|
@ -53,16 +53,10 @@ class Partitioner(object):
|
|||||||
ndata[ndata == -np.inf] = 0
|
ndata[ndata == -np.inf] = 0
|
||||||
_min = np.nanmin(ndata)
|
_min = np.nanmin(ndata)
|
||||||
|
|
||||||
if _min < 0:
|
self.min = float(_min * 1.1 if _min < 0 else _min * 0.9)
|
||||||
self.min = _min * 1.1
|
|
||||||
else:
|
|
||||||
self.min = _min * 0.9
|
|
||||||
|
|
||||||
_max = max(ndata)
|
_max = max(ndata)
|
||||||
if _max > 0:
|
self.max = float(_max * 1.1 if _max > 0 else _max * 0.9)
|
||||||
self.max = _max * 1.1
|
|
||||||
else:
|
|
||||||
self.max = _max * 0.9
|
|
||||||
|
|
||||||
self.sets = self.build(ndata)
|
self.sets = self.build(ndata)
|
||||||
|
|
||||||
|
@ -11,17 +11,17 @@ import pandas as pd
|
|||||||
from pyFTS.data import TAIEX, NASDAQ, SP500, artificial
|
from pyFTS.data import TAIEX, NASDAQ, SP500, artificial
|
||||||
|
|
||||||
datasets = {
|
datasets = {
|
||||||
"TAIEX": TAIEX.get_data()[:4000],
|
#"TAIEX": TAIEX.get_data()[:4000],
|
||||||
"SP500": SP500.get_data()[10000:14000],
|
"SP500": SP500.get_data()[10000:14000],
|
||||||
"NASDAQ": NASDAQ.get_data()[:4000],
|
#"NASDAQ": NASDAQ.get_data()[:4000],
|
||||||
# Incremental Mean and Incremental Variance
|
# 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
|
# 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
|
# 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
|
# 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
|
train_split = 2000
|
||||||
@ -34,9 +34,9 @@ tdiff = Transformations.Differential(1)
|
|||||||
boxcox = Transformations.BoxCox(0)
|
boxcox = Transformations.BoxCox(0)
|
||||||
|
|
||||||
transformations = {
|
transformations = {
|
||||||
'None': None,
|
#'None': None,
|
||||||
'Differential(1)': tdiff,
|
'Differential(1)': tdiff,
|
||||||
'BoxCox(0)': boxcox
|
#'BoxCox(0)': boxcox
|
||||||
}
|
}
|
||||||
|
|
||||||
from pyFTS.partitioners import Grid, Util as pUtil
|
from pyFTS.partitioners import Grid, Util as pUtil
|
||||||
@ -78,6 +78,8 @@ for ds in datasets.keys():
|
|||||||
for ds in datasets.keys():
|
for ds in datasets.keys():
|
||||||
dataset = datasets[ds]
|
dataset = datasets[ds]
|
||||||
|
|
||||||
|
print(ds)
|
||||||
|
|
||||||
for tf in transformations.keys():
|
for tf in transformations.keys():
|
||||||
transformation = transformations[tf]
|
transformation = transformations[tf]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user