From 039dca9d5d5c0bd9685269eb2c8896a1e65ce557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Mon, 30 Sep 2019 19:28:04 -0300 Subject: [PATCH] ResidualAnalysis bugfix --- pyFTS/benchmarks/ResidualAnalysis.py | 2 +- pyFTS/tests/general.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pyFTS/benchmarks/ResidualAnalysis.py b/pyFTS/benchmarks/ResidualAnalysis.py index c8a7b54..5a770ea 100644 --- a/pyFTS/benchmarks/ResidualAnalysis.py +++ b/pyFTS/benchmarks/ResidualAnalysis.py @@ -69,7 +69,7 @@ def plot_residuals_by_model(targets, models, tam=[8, 8], save=False, file=None): else: ax = axes forecasts = mfts.predict(targets) - res = residuals(targets, forecasts, mfts.order+1) + res = residuals(targets, forecasts, mfts.order) mu = np.mean(res) sig = np.std(res) diff --git a/pyFTS/tests/general.py b/pyFTS/tests/general.py index 69a96c7..830ed04 100644 --- a/pyFTS/tests/general.py +++ b/pyFTS/tests/general.py @@ -17,7 +17,11 @@ from pyFTS.common import Transformations, Membership, Util from pyFTS.benchmarks import arima, quantreg, BSTS, gaussianproc, knn from pyFTS.fcm import fts, common, GA -from pyFTS.data import TAIEX, NASDAQ, SP500 +from pyFTS.common import Transformations + +tdiff = Transformations.Differential(1) + +boxcox = Transformations.BoxCox(0) from pyFTS.data import TAIEX, NASDAQ, SP500 from pyFTS.common import Util @@ -28,10 +32,18 @@ test = TAIEX.get_data()[1800:2000] from pyFTS.models import pwfts from pyFTS.partitioners import Grid -fs = Grid.GridPartitioner(data=train, npart=45) +fs = Grid.GridPartitioner(data=train, npart=15, transformation=tdiff) -model = pwfts.ProbabilisticWeightedFTS(partitioner=fs, order=1) +#model = pwfts.ProbabilisticWeightedFTS(partitioner=fs, order=1) + +model = chen.ConventionalFTS(partitioner=fs) +model.append_transformation(tdiff) model.fit(train) + +from pyFTS.benchmarks import ResidualAnalysis as ra + +ra.plot_residuals_by_model(test, [model]) + horizon = 10 ''' forecasts = model.predict(test[9:20], type='point') @@ -41,7 +53,7 @@ distributions = model.predict(test[9:20], type='distribution') forecasts = model.predict(test[9:20], type='point', steps_ahead=horizon) intervals = model.predict(test[9:20], type='interval', steps_ahead=horizon) ''' -distributions = model.predict(test[9:20], type='distribution', steps_ahead=horizon) +#distributions = model.predict(test[9:20], type='distribution', steps_ahead=horizon) '''