From 1168365a17e0f3de45a1b67ed38ffa296e4b85bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido?= Date: Sun, 23 Jun 2019 09:47:06 -0300 Subject: [PATCH] common.plot_distributions_tiled --- pyFTS/common/Util.py | 36 +++++++++++++++++++++++++++++++++++- pyFTS/tests/hyperparam.py | 2 +- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/pyFTS/common/Util.py b/pyFTS/common/Util.py index 8b44364..4496c98 100644 --- a/pyFTS/common/Util.py +++ b/pyFTS/common/Util.py @@ -163,7 +163,7 @@ def plot_distribution(ax, cmap, probabilitydist, fig, time_from, reference_data= def plot_distribution2(probabilitydist, data, **kwargs): """ - Plot distributions over the time (x-axis) + Plot distributions in y-axis over the time (x-axis) :param probabilitydist: the forecasted probability distributions to plot :param data: the original test sample @@ -226,6 +226,40 @@ def plot_distribution2(probabilitydist, data, **kwargs): cb.set_label('Density') +def plot_distribution_tiled(distributions,data=None,rows=5,cols=5,index=None,axis=None,size=[10,20]): + """ + Plot one distribution individually in each axis, with probability in y-axis and UoD on x-axis + + :param distributions: + :param data: + :param rows: + :param cols: + :param index: + :param axis: + :param size: + :return: + """ + + if axis is None: + fig, axis = plt.subplots(nrows=rows, ncols=cols, figsize=size) + + for ct in range(rows*cols): + col = ct % cols + row = ct // cols + if index is None: + ix = ct + else: + ix =index[ct] + forecast = distributions[ix] + forecast.plot(axis=axis[row][col]) + if data is not None: + axis[row][col].axvline(data[ix]) + axis[row][col].set_title('t+{}'.format(ix)) + axis[row][col].set_xlabel(None) + + plt.tight_layout() + + def plot_interval(axis, intervals, order, label, color='red', typeonlegend=False, ls='-', linewidth=1): """ Plot forecasted intervals on matplotlib diff --git a/pyFTS/tests/hyperparam.py b/pyFTS/tests/hyperparam.py index b62e7dd..899299a 100644 --- a/pyFTS/tests/hyperparam.py +++ b/pyFTS/tests/hyperparam.py @@ -46,7 +46,7 @@ datsetname, dataset = get_dataset() ret = Evolutionary.execute(datsetname, dataset, ngen=30, npop=20,psel=0.6, pcross=.5, pmut=.3, window_size=10000, train_rate=.9, increment_rate=.3, - experiments=2, + experiments=1, fts_method=pwfts.ProbabilisticWeightedFTS, database_file='experiments.db', distributed='dispy', nodes=nodes)