Bugfixes
This commit is contained in:
parent
7d5dae21e8
commit
5563af3079
@ -276,6 +276,7 @@ def heavyside_cdf(bins, targets):
|
|||||||
df = pd.DataFrame(ret, columns=bins)
|
df = pd.DataFrame(ret, columns=bins)
|
||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
def crps(targets, densities):
|
def crps(targets, densities):
|
||||||
'''
|
'''
|
||||||
Continuous Ranked Probability Score
|
Continuous Ranked Probability Score
|
||||||
|
@ -393,14 +393,19 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS):
|
|||||||
return point <= lower_set.lower or point >= upper_set.upper
|
return point <= lower_set.lower or point >= upper_set.upper
|
||||||
|
|
||||||
def forecast_ahead(self, data, steps, **kwargs):
|
def forecast_ahead(self, data, steps, **kwargs):
|
||||||
ret = [data[k] for k in np.arange(len(data) - self.order, len(data))]
|
|
||||||
|
|
||||||
for k in np.arange(self.order - 1, steps):
|
l = len(data)
|
||||||
|
|
||||||
|
start = kwargs.get('start', self.order)
|
||||||
|
|
||||||
|
ret = data[start - self.order: start].tolist()
|
||||||
|
|
||||||
|
for k in np.arange(self.order, steps+self.order):
|
||||||
|
|
||||||
if self.__check_point_bounds(ret[-1]) :
|
if self.__check_point_bounds(ret[-1]) :
|
||||||
ret.append(ret[-1])
|
ret.append(ret[-1])
|
||||||
else:
|
else:
|
||||||
mp = self.forecast([ret[x] for x in np.arange(k - self.order, k)], **kwargs)
|
mp = self.forecast(ret[k - self.order: k], **kwargs)
|
||||||
ret.append(mp[0])
|
ret.append(mp[0])
|
||||||
|
|
||||||
return ret[self.order:]
|
return ret[self.order:]
|
||||||
@ -423,7 +428,9 @@ class ProbabilisticWeightedFTS(ifts.IntervalFTS):
|
|||||||
|
|
||||||
ret = [[k, k] for k in sample]
|
ret = [[k, k] for k in sample]
|
||||||
|
|
||||||
for k in np.arange(self.order, steps+self.order):
|
ret.append(self.forecast_interval(sample)[0])
|
||||||
|
|
||||||
|
for k in np.arange(self.order+1, steps+self.order):
|
||||||
|
|
||||||
if len(ret) > 0 and self.__check_interval_bounds(ret[-1]):
|
if len(ret) > 0 and self.__check_interval_bounds(ret[-1]):
|
||||||
ret.append(ret[-1])
|
ret.append(ret[-1])
|
||||||
|
@ -50,7 +50,7 @@ bchmk.sliding_window_benchmarks(dataset, 1000, train=0.8, inc=0.2,
|
|||||||
progress=False, type="point",
|
progress=False, type="point",
|
||||||
#steps_ahead=[1,2,4,6,8,10],
|
#steps_ahead=[1,2,4,6,8,10],
|
||||||
distributed=True, nodes=['192.168.0.110', '192.168.0.107', '192.168.0.106'],
|
distributed=True, nodes=['192.168.0.110', '192.168.0.107', '192.168.0.106'],
|
||||||
file="benchmarks.db", dataset="NASDAQ", tag="comparisons")
|
file="benchmarks.db", dataset="TAIEX", tag="comparisons")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ print(Measures.get_distribution_statistics(dataset[800:1000], model, steps_ahead
|
|||||||
'''
|
'''
|
||||||
#'''
|
#'''
|
||||||
|
|
||||||
types = ['interval']#['point','interval','distribution']
|
types = ['point','interval','distribution']
|
||||||
benchmark_methods=[[arima.ARIMA for k in range(8)] + [quantreg.QuantileRegression for k in range(4)]]
|
benchmark_methods=[[arima.ARIMA for k in range(8)] + [quantreg.QuantileRegression for k in range(4)]]
|
||||||
'''
|
'''
|
||||||
benchmark_methods=[
|
benchmark_methods=[
|
||||||
@ -136,31 +136,35 @@ benchmark_methods_parameters= [
|
|||||||
]
|
]
|
||||||
]'''
|
]'''
|
||||||
dataset_name = "SP500"
|
dataset_name = "SP500"
|
||||||
tag = "comparisons"
|
tag = "ahead2"
|
||||||
|
|
||||||
from pyFTS.benchmarks import arima, naive, quantreg
|
from pyFTS.benchmarks import arima, naive, quantreg
|
||||||
|
|
||||||
for ct, type in enumerate(types):
|
for ct, type in enumerate(types):
|
||||||
|
|
||||||
bchmk.sliding_window_benchmarks(dataset, 1000, train=0.8, inc=0.2,
|
|
||||||
benchmark_models=True,
|
|
||||||
benchmark_methods=benchmark_methods[ct],
|
|
||||||
benchmark_methods_parameters=benchmark_methods_parameters[ct],
|
|
||||||
transformations=[None],
|
|
||||||
orders=[1,2,3],
|
|
||||||
partitions=np.arange(15, 85, 5),
|
|
||||||
progress=False, type=type,
|
|
||||||
distributed=True, nodes=['192.168.0.110', '192.168.0.107','192.168.0.106'],
|
|
||||||
file="benchmarks.db", dataset=dataset_name, tag=tag)
|
|
||||||
|
|
||||||
bchmk.sliding_window_benchmarks(dataset, 1000, train=0.8, inc=0.2,
|
bchmk.sliding_window_benchmarks(dataset, 1000, train=0.8, inc=0.2,
|
||||||
benchmark_models=True,
|
methods=[pwfts.ProbabilisticWeightedFTS],
|
||||||
benchmark_methods=benchmark_methods[ct],
|
benchmark_models=False,
|
||||||
benchmark_methods_parameters=benchmark_methods_parameters[ct],
|
#benchmark_methods=benchmark_methods[ct],
|
||||||
|
#benchmark_methods_parameters=benchmark_methods_parameters[ct],
|
||||||
transformations=[tdiff],
|
transformations=[tdiff],
|
||||||
orders=[1, 2, 3],
|
orders=[1], #, 2, 3],
|
||||||
partitiTAIEXons=np.arange(3, 35, 2),
|
partitions=[5], #np.arange(3, 35, 2),
|
||||||
progress=False, type=type,
|
progress=False, type=type,
|
||||||
|
steps_ahead=[2, 4, 6, 8, 10],
|
||||||
|
distributed=True, nodes=['192.168.0.110', '192.168.0.107', '192.168.0.106'],
|
||||||
|
file="benchmarks.db", dataset=dataset_name, tag=tag)
|
||||||
|
bchmk.sliding_window_benchmarks(dataset, 1000, train=0.8, inc=0.2,
|
||||||
|
methods=[pwfts.ProbabilisticWeightedFTS],
|
||||||
|
benchmark_models=False,
|
||||||
|
#benchmark_methods=benchmark_methods[ct],
|
||||||
|
#benchmark_methods_parameters=benchmark_methods_parameters[ct],
|
||||||
|
transformations=[None],
|
||||||
|
orders=[1], #,2,3],
|
||||||
|
partitions=[30], #np.arange(15, 85, 5),
|
||||||
|
progress=False, type=type,
|
||||||
|
steps_ahead=[2, 4, 6, 8, 10],
|
||||||
distributed=True, nodes=['192.168.0.110', '192.168.0.107','192.168.0.106'],
|
distributed=True, nodes=['192.168.0.110', '192.168.0.107','192.168.0.106'],
|
||||||
file="benchmarks.db", dataset=dataset_name, tag=tag)
|
file="benchmarks.db", dataset=dataset_name, tag=tag)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user