Updating documentiation
This commit is contained in:
parent
80046c306e
commit
6b8607cf3c
BIN
docs/build/doctrees/environment.pickle
vendored
BIN
docs/build/doctrees/environment.pickle
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.benchmarks.doctree
vendored
BIN
docs/build/doctrees/pyFTS.benchmarks.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.common.doctree
vendored
BIN
docs/build/doctrees/pyFTS.common.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.hyperparam.doctree
vendored
BIN
docs/build/doctrees/pyFTS.hyperparam.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.models.doctree
vendored
BIN
docs/build/doctrees/pyFTS.models.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.models.ensemble.doctree
vendored
BIN
docs/build/doctrees/pyFTS.models.ensemble.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.models.incremental.doctree
vendored
BIN
docs/build/doctrees/pyFTS.models.incremental.doctree
vendored
Binary file not shown.
Binary file not shown.
@ -84,13 +84,11 @@
|
||||
<span class="kn">import</span> <span class="nn">traceback</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">matplotlib</span> <span class="k">as</span> <span class="nn">plt</span>
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.cm</span> <span class="k">as</span> <span class="nn">cmx</span>
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.colors</span> <span class="k">as</span> <span class="nn">pltcolors</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">mpl_toolkits.mplot3d</span> <span class="k">import</span> <span class="n">Axes3D</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.probabilistic</span> <span class="k">import</span> <span class="n">ProbabilityDistribution</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="k">import</span> <span class="n">Transformations</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models</span> <span class="k">import</span> <span class="n">song</span><span class="p">,</span> <span class="n">chen</span><span class="p">,</span> <span class="n">yu</span><span class="p">,</span> <span class="n">ismailefendi</span><span class="p">,</span> <span class="n">sadaei</span><span class="p">,</span> <span class="n">hofts</span><span class="p">,</span> <span class="n">pwfts</span><span class="p">,</span> <span class="n">ifts</span><span class="p">,</span> <span class="n">cheng</span><span class="p">,</span> <span class="n">hwang</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.multivariate</span> <span class="k">import</span> <span class="n">mvfts</span><span class="p">,</span> <span class="n">wmvfts</span><span class="p">,</span> <span class="n">cmvfts</span>
|
||||
@ -100,12 +98,6 @@
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="k">import</span> <span class="n">Util</span> <span class="k">as</span> <span class="n">cUtil</span>
|
||||
<span class="c1"># from sklearn.cross_validation import KFold</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="k">import</span> <span class="n">Grid</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib</span> <span class="k">import</span> <span class="n">rc</span>
|
||||
|
||||
<span class="c1">#rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})</span>
|
||||
<span class="c1">## for Palatino and other serif fonts use:</span>
|
||||
<span class="c1">#rc('font',**{'family':'serif','serif':['Palatino']})</span>
|
||||
<span class="c1">#rc('text', usetex=True)</span>
|
||||
|
||||
<span class="n">colors</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'grey'</span><span class="p">,</span> <span class="s1">'darkgrey'</span><span class="p">,</span> <span class="s1">'rosybrown'</span><span class="p">,</span> <span class="s1">'maroon'</span><span class="p">,</span> <span class="s1">'red'</span><span class="p">,</span><span class="s1">'orange'</span><span class="p">,</span> <span class="s1">'gold'</span><span class="p">,</span> <span class="s1">'yellow'</span><span class="p">,</span> <span class="s1">'olive'</span><span class="p">,</span> <span class="s1">'green'</span><span class="p">,</span>
|
||||
<span class="s1">'darkgreen'</span><span class="p">,</span> <span class="s1">'cyan'</span><span class="p">,</span> <span class="s1">'lightblue'</span><span class="p">,</span><span class="s1">'blue'</span><span class="p">,</span> <span class="s1">'darkblue'</span><span class="p">,</span> <span class="s1">'purple'</span><span class="p">,</span> <span class="s1">'darkviolet'</span> <span class="p">]</span>
|
||||
@ -292,10 +284,10 @@
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Type parameter has a unkown value!"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">distributed</span><span class="p">:</span>
|
||||
<span class="kn">import</span> <span class="nn">dispy</span><span class="o">,</span> <span class="nn">dispy.httpd</span>
|
||||
<span class="kn">import</span> <span class="nn">pyFTS.distributed.dispy</span> <span class="k">as</span> <span class="nn">dispy</span>
|
||||
|
||||
<span class="n">nodes</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"nodes"</span><span class="p">,</span> <span class="p">[</span><span class="s1">'127.0.0.1'</span><span class="p">])</span>
|
||||
<span class="n">cluster</span><span class="p">,</span> <span class="n">http_server</span> <span class="o">=</span> <span class="n">cUtil</span><span class="o">.</span><span class="n">start_dispy_cluster</span><span class="p">(</span><span class="n">experiment_method</span><span class="p">,</span> <span class="n">nodes</span><span class="p">)</span>
|
||||
<span class="n">cluster</span><span class="p">,</span> <span class="n">http_server</span> <span class="o">=</span> <span class="n">dispy</span><span class="o">.</span><span class="n">start_dispy_cluster</span><span class="p">(</span><span class="n">experiment_method</span><span class="p">,</span> <span class="n">nodes</span><span class="p">)</span>
|
||||
|
||||
<span class="n">jobs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
@ -380,7 +372,7 @@
|
||||
<span class="k">if</span> <span class="n">progress</span><span class="p">:</span>
|
||||
<span class="n">progressbar</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">job</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">job</span><span class="o">.</span><span class="n">status</span> <span class="o">==</span> <span class="n">dispy</span><span class="o">.</span><span class="n">DispyJob</span><span class="o">.</span><span class="n">Finished</span> <span class="ow">and</span> <span class="n">job</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">job</span><span class="o">.</span><span class="n">status</span> <span class="o">==</span> <span class="n">dispy</span><span class="o">.</span><span class="n">dispy</span><span class="o">.</span><span class="n">DispyJob</span><span class="o">.</span><span class="n">Finished</span> <span class="ow">and</span> <span class="n">job</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">result</span>
|
||||
<span class="n">synthesis_method</span><span class="p">(</span><span class="n">dataset</span><span class="p">,</span> <span class="n">tag</span><span class="p">,</span> <span class="n">tmp</span><span class="p">,</span> <span class="n">conn</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
@ -391,7 +383,7 @@
|
||||
|
||||
<span class="n">cluster</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span> <span class="c1"># wait for all jobs to finish</span>
|
||||
|
||||
<span class="n">cUtil</span><span class="o">.</span><span class="n">stop_dispy_cluster</span><span class="p">(</span><span class="n">cluster</span><span class="p">,</span> <span class="n">http_server</span><span class="p">)</span>
|
||||
<span class="n">dispy</span><span class="o">.</span><span class="n">stop_dispy_cluster</span><span class="p">(</span><span class="n">cluster</span><span class="p">,</span> <span class="n">http_server</span><span class="p">)</span>
|
||||
|
||||
<span class="n">conn</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div>
|
||||
|
||||
@ -755,145 +747,11 @@
|
||||
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_compared_intervals_ahead"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_compared_intervals_ahead">[docs]</a><span class="k">def</span> <span class="nf">plot_compared_intervals_ahead</span><span class="p">(</span><span class="n">original</span><span class="p">,</span> <span class="n">models</span><span class="p">,</span> <span class="n">colors</span><span class="p">,</span> <span class="n">distributions</span><span class="p">,</span> <span class="n">time_from</span><span class="p">,</span> <span class="n">time_to</span><span class="p">,</span> <span class="n">intervals</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
|
||||
<span class="n">save</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">tam</span><span class="o">=</span><span class="p">[</span><span class="mi">20</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="n">resolution</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">cmap</span><span class="o">=</span><span class="s1">'Blues'</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">1.5</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Plot the forecasts of several one step ahead models, by point or by interval</span>
|
||||
|
||||
<span class="sd"> :param original: Original time series data (list)</span>
|
||||
<span class="sd"> :param models: List of models to compare</span>
|
||||
<span class="sd"> :param colors: List of models colors</span>
|
||||
<span class="sd"> :param distributions: True to plot a distribution</span>
|
||||
<span class="sd"> :param time_from: index of data poit to start the ahead forecasting</span>
|
||||
<span class="sd"> :param time_to: number of steps ahead to forecast</span>
|
||||
<span class="sd"> :param interpol: Fill space between distribution plots</span>
|
||||
<span class="sd"> :param save: Save the picture on file</span>
|
||||
<span class="sd"> :param file: Filename to save the picture</span>
|
||||
<span class="sd"> :param tam: Size of the picture</span>
|
||||
<span class="sd"> :param resolution: </span>
|
||||
<span class="sd"> :param cmap: Color map to be used on distribution plot </span>
|
||||
<span class="sd"> :param option: Distribution type to be passed for models</span>
|
||||
<span class="sd"> :return: </span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="n">tam</span><span class="p">)</span>
|
||||
<span class="n">ax</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">add_subplot</span><span class="p">(</span><span class="mi">111</span><span class="p">)</span>
|
||||
|
||||
<span class="n">cm</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">get_cmap</span><span class="p">(</span><span class="n">cmap</span><span class="p">)</span>
|
||||
<span class="n">cNorm</span> <span class="o">=</span> <span class="n">pltcolors</span><span class="o">.</span><span class="n">Normalize</span><span class="p">(</span><span class="n">vmin</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">scalarMap</span> <span class="o">=</span> <span class="n">cmx</span><span class="o">.</span><span class="n">ScalarMappable</span><span class="p">(</span><span class="n">norm</span><span class="o">=</span><span class="n">cNorm</span><span class="p">,</span> <span class="n">cmap</span><span class="o">=</span><span class="n">cm</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">resolution</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">resolution</span> <span class="o">=</span> <span class="p">(</span><span class="nb">max</span><span class="p">(</span><span class="n">original</span><span class="p">)</span> <span class="o">-</span> <span class="nb">min</span><span class="p">(</span><span class="n">original</span><span class="p">))</span> <span class="o">/</span> <span class="mi">100</span>
|
||||
|
||||
<span class="n">mi</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">ma</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">count</span><span class="p">,</span> <span class="n">fts</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">models</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">fts</span><span class="o">.</span><span class="n">has_probability_forecasting</span> <span class="ow">and</span> <span class="n">distributions</span><span class="p">[</span><span class="n">count</span><span class="p">]:</span>
|
||||
<span class="n">density</span> <span class="o">=</span> <span class="n">fts</span><span class="o">.</span><span class="n">forecast_ahead_distribution</span><span class="p">(</span><span class="n">original</span><span class="p">[</span><span class="n">time_from</span> <span class="o">-</span> <span class="n">fts</span><span class="o">.</span><span class="n">order</span><span class="p">:</span><span class="n">time_from</span><span class="p">],</span> <span class="n">time_to</span><span class="p">,</span>
|
||||
<span class="n">resolution</span><span class="o">=</span><span class="n">resolution</span><span class="p">)</span>
|
||||
|
||||
<span class="c1">#plot_density_scatter(ax, cmap, density, fig, resolution, time_from, time_to)</span>
|
||||
<span class="n">plot_density_rectange</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">cm</span><span class="p">,</span> <span class="n">density</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">resolution</span><span class="p">,</span> <span class="n">time_from</span><span class="p">,</span> <span class="n">time_to</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">fts</span><span class="o">.</span><span class="n">has_interval_forecasting</span> <span class="ow">and</span> <span class="n">intervals</span><span class="p">:</span>
|
||||
<span class="n">forecasts</span> <span class="o">=</span> <span class="n">fts</span><span class="o">.</span><span class="n">forecast_ahead_interval</span><span class="p">(</span><span class="n">original</span><span class="p">[</span><span class="n">time_from</span> <span class="o">-</span> <span class="n">fts</span><span class="o">.</span><span class="n">order</span><span class="p">:</span><span class="n">time_from</span><span class="p">],</span> <span class="n">time_to</span><span class="p">)</span>
|
||||
<span class="n">lower</span> <span class="o">=</span> <span class="p">[</span><span class="n">kk</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">forecasts</span><span class="p">]</span>
|
||||
<span class="n">upper</span> <span class="o">=</span> <span class="p">[</span><span class="n">kk</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">forecasts</span><span class="p">]</span>
|
||||
<span class="n">mi</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">min</span><span class="p">(</span><span class="n">lower</span><span class="p">))</span>
|
||||
<span class="n">ma</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">max</span><span class="p">(</span><span class="n">upper</span><span class="p">))</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">time_from</span> <span class="o">-</span> <span class="n">fts</span><span class="o">.</span><span class="n">order</span><span class="p">):</span>
|
||||
<span class="n">lower</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">upper</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">lower</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">count</span><span class="p">],</span> <span class="n">label</span><span class="o">=</span><span class="n">fts</span><span class="o">.</span><span class="n">shortname</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">upper</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">count</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="o">*</span><span class="mf">1.5</span><span class="p">)</span>
|
||||
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">original</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">'black'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">"Original"</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="o">*</span><span class="mf">1.5</span><span class="p">)</span>
|
||||
<span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">get_legend_handles_labels</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="kc">True</span> <span class="ow">in</span> <span class="n">distributions</span><span class="p">:</span>
|
||||
<span class="n">lgd</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span><span class="p">,</span> <span class="n">loc</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">lgd</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span><span class="p">,</span> <span class="n">loc</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">bbox_to_anchor</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
|
||||
<span class="n">_mi</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">mi</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">_mi</span> <span class="o"><</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">_mi</span> <span class="o">*=</span> <span class="mf">1.1</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">_mi</span> <span class="o">*=</span> <span class="mf">0.9</span>
|
||||
<span class="n">_ma</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">ma</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">_ma</span> <span class="o"><</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">_ma</span> <span class="o">*=</span> <span class="mf">0.9</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">_ma</span> <span class="o">*=</span> <span class="mf">1.1</span>
|
||||
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">([</span><span class="n">_mi</span><span class="p">,</span> <span class="n">_ma</span><span class="p">])</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'F(T)'</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'T'</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">original</span><span class="p">)])</span>
|
||||
|
||||
<span class="n">cUtil</span><span class="o">.</span><span class="n">show_and_save_image</span><span class="p">(</span><span class="n">fig</span><span class="p">,</span> <span class="n">file</span><span class="p">,</span> <span class="n">save</span><span class="p">,</span> <span class="n">lgd</span><span class="o">=</span><span class="n">lgd</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_density_rectange"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_density_rectange">[docs]</a><span class="k">def</span> <span class="nf">plot_density_rectange</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">cmap</span><span class="p">,</span> <span class="n">density</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">resolution</span><span class="p">,</span> <span class="n">time_from</span><span class="p">,</span> <span class="n">time_to</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Auxiliar function to plot_compared_intervals_ahead</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib.patches</span> <span class="k">import</span> <span class="n">Rectangle</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib.collections</span> <span class="k">import</span> <span class="n">PatchCollection</span>
|
||||
<span class="n">patches</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">colors</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">density</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">density</span><span class="o">.</span><span class="n">columns</span><span class="p">:</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="n">Rectangle</span><span class="p">((</span><span class="n">time_from</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">resolution</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">lw</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="n">patches</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
|
||||
<span class="n">colors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">density</span><span class="p">[</span><span class="n">y</span><span class="p">][</span><span class="n">x</span><span class="p">]</span><span class="o">*</span><span class="mi">5</span><span class="p">)</span>
|
||||
<span class="n">pc</span> <span class="o">=</span> <span class="n">PatchCollection</span><span class="p">(</span><span class="n">patches</span><span class="o">=</span><span class="n">patches</span><span class="p">,</span> <span class="n">match_original</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_clim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_cmap</span><span class="p">(</span><span class="n">cmap</span><span class="p">)</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_array</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">colors</span><span class="p">))</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">add_collection</span><span class="p">(</span><span class="n">pc</span><span class="p">)</span>
|
||||
<span class="n">cb</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">colorbar</span><span class="p">(</span><span class="n">pc</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>
|
||||
<span class="n">cb</span><span class="o">.</span><span class="n">set_label</span><span class="p">(</span><span class="s1">'Density'</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_distribution"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_distribution">[docs]</a><span class="k">def</span> <span class="nf">plot_distribution</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">cmap</span><span class="p">,</span> <span class="n">probabilitydist</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">time_from</span><span class="p">,</span> <span class="n">reference_data</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib.patches</span> <span class="k">import</span> <span class="n">Rectangle</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib.collections</span> <span class="k">import</span> <span class="n">PatchCollection</span>
|
||||
<span class="n">patches</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">colors</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">probabilitydist</span><span class="p">):</span>
|
||||
<span class="n">disp</span> <span class="o">=</span> <span class="mf">0.0</span>
|
||||
<span class="k">if</span> <span class="n">reference_data</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">disp</span> <span class="o">=</span> <span class="n">reference_data</span><span class="p">[</span><span class="n">time_from</span><span class="o">+</span><span class="n">ct</span><span class="p">]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">dt</span><span class="o">.</span><span class="n">bins</span><span class="p">:</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="n">Rectangle</span><span class="p">((</span><span class="n">time_from</span><span class="o">+</span><span class="n">ct</span><span class="p">,</span> <span class="n">y</span><span class="o">+</span><span class="n">disp</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">resolution</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">lw</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="n">patches</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
|
||||
<span class="n">colors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dt</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="n">y</span><span class="p">))</span>
|
||||
<span class="n">scale</span> <span class="o">=</span> <span class="n">Transformations</span><span class="o">.</span><span class="n">Scale</span><span class="p">()</span>
|
||||
<span class="n">colors</span> <span class="o">=</span> <span class="n">scale</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">colors</span><span class="p">)</span>
|
||||
<span class="n">pc</span> <span class="o">=</span> <span class="n">PatchCollection</span><span class="p">(</span><span class="n">patches</span><span class="o">=</span><span class="n">patches</span><span class="p">,</span> <span class="n">match_original</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_clim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_cmap</span><span class="p">(</span><span class="n">cmap</span><span class="p">)</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_array</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">colors</span><span class="p">))</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">add_collection</span><span class="p">(</span><span class="n">pc</span><span class="p">)</span>
|
||||
<span class="n">cb</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">colorbar</span><span class="p">(</span><span class="n">pc</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>
|
||||
<span class="n">cb</span><span class="o">.</span><span class="n">set_label</span><span class="p">(</span><span class="s1">'Density'</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_interval"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_interval">[docs]</a><span class="k">def</span> <span class="nf">plot_interval</span><span class="p">(</span><span class="n">axis</span><span class="p">,</span> <span class="n">intervals</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">'red'</span><span class="p">,</span> <span class="n">typeonlegend</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">ls</span><span class="o">=</span><span class="s1">'-'</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">lower</span> <span class="o">=</span> <span class="p">[</span><span class="n">kk</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">intervals</span><span class="p">]</span>
|
||||
<span class="n">upper</span> <span class="o">=</span> <span class="p">[</span><span class="n">kk</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">intervals</span><span class="p">]</span>
|
||||
<span class="n">mi</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">lower</span><span class="p">)</span> <span class="o">*</span> <span class="mf">0.95</span>
|
||||
<span class="n">ma</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1.05</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">order</span><span class="p">):</span>
|
||||
<span class="n">lower</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">upper</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">typeonlegend</span><span class="p">:</span> <span class="n">label</span> <span class="o">+=</span> <span class="s2">" (Interval)"</span>
|
||||
<span class="n">axis</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">lower</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">ls</span><span class="o">=</span><span class="n">ls</span><span class="p">,</span><span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="p">)</span>
|
||||
<span class="n">axis</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">upper</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">,</span> <span class="n">ls</span><span class="o">=</span><span class="n">ls</span><span class="p">,</span><span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">mi</span><span class="p">,</span> <span class="n">ma</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_point"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_point">[docs]</a><span class="k">def</span> <span class="nf">plot_point</span><span class="p">(</span><span class="n">axis</span><span class="p">,</span> <span class="n">points</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">'red'</span><span class="p">,</span> <span class="n">ls</span><span class="o">=</span><span class="s1">'-'</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">mi</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">points</span><span class="p">)</span> <span class="o">*</span> <span class="mf">0.95</span>
|
||||
@ -954,7 +812,7 @@
|
||||
<span class="n">ls</span> <span class="o">=</span> <span class="s2">"-"</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">ls</span> <span class="o">=</span> <span class="s2">"--"</span>
|
||||
<span class="n">tmpmi</span><span class="p">,</span> <span class="n">tmpma</span> <span class="o">=</span> <span class="n">plot_interval</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">forecasts</span><span class="p">,</span> <span class="n">fts</span><span class="o">.</span><span class="n">order</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">lbl</span><span class="p">,</span> <span class="n">typeonlegend</span><span class="o">=</span><span class="n">typeonlegend</span><span class="p">,</span>
|
||||
<span class="n">tmpmi</span><span class="p">,</span> <span class="n">tmpma</span> <span class="o">=</span> <span class="n">Util</span><span class="o">.</span><span class="n">plot_interval</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">forecasts</span><span class="p">,</span> <span class="n">fts</span><span class="o">.</span><span class="n">order</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">lbl</span><span class="p">,</span> <span class="n">typeonlegend</span><span class="o">=</span><span class="n">typeonlegend</span><span class="p">,</span>
|
||||
<span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">count</span><span class="p">],</span> <span class="n">ls</span><span class="o">=</span><span class="n">ls</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="p">)</span>
|
||||
<span class="n">mi</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmpmi</span><span class="p">)</span>
|
||||
<span class="n">ma</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmpma</span><span class="p">)</span>
|
||||
@ -974,15 +832,7 @@
|
||||
<span class="c1">#Util.show_and_save_image(fig, file, save, lgd=legends)</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_probability_distributions"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_probability_distributions">[docs]</a><span class="k">def</span> <span class="nf">plot_probability_distributions</span><span class="p">(</span><span class="n">pmfs</span><span class="p">,</span> <span class="n">lcolors</span><span class="p">,</span> <span class="n">tam</span><span class="o">=</span><span class="p">[</span><span class="mi">15</span><span class="p">,</span> <span class="mi">7</span><span class="p">]):</span>
|
||||
<span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="n">tam</span><span class="p">)</span>
|
||||
<span class="n">ax</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">add_subplot</span><span class="p">(</span><span class="mi">111</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">m</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">pmfs</span><span class="p">,</span><span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="n">m</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">lcolors</span><span class="p">[</span><span class="n">k</span><span class="p">])</span>
|
||||
|
||||
<span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">get_legend_handles_labels</span><span class="p">()</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
|
||||
|
190
docs/build/html/_modules/pyFTS/common/Util.html
vendored
190
docs/build/html/_modules/pyFTS/common/Util.html
vendored
@ -80,9 +80,199 @@
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
|
||||
<span class="kn">import</span> <span class="nn">dill</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.cm</span> <span class="k">as</span> <span class="nn">cmx</span>
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.colors</span> <span class="k">as</span> <span class="nn">pltcolors</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.probabilistic</span> <span class="k">import</span> <span class="n">ProbabilityDistribution</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="k">import</span> <span class="n">Transformations</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_compared_intervals_ahead"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Util.plot_compared_intervals_ahead">[docs]</a><span class="k">def</span> <span class="nf">plot_compared_intervals_ahead</span><span class="p">(</span><span class="n">original</span><span class="p">,</span> <span class="n">models</span><span class="p">,</span> <span class="n">colors</span><span class="p">,</span> <span class="n">distributions</span><span class="p">,</span> <span class="n">time_from</span><span class="p">,</span> <span class="n">time_to</span><span class="p">,</span> <span class="n">intervals</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
|
||||
<span class="n">save</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">tam</span><span class="o">=</span><span class="p">[</span><span class="mi">20</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="n">resolution</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">cmap</span><span class="o">=</span><span class="s1">'Blues'</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">1.5</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Plot the forecasts of several one step ahead models, by point or by interval</span>
|
||||
|
||||
<span class="sd"> :param original: Original time series data (list)</span>
|
||||
<span class="sd"> :param models: List of models to compare</span>
|
||||
<span class="sd"> :param colors: List of models colors</span>
|
||||
<span class="sd"> :param distributions: True to plot a distribution</span>
|
||||
<span class="sd"> :param time_from: index of data poit to start the ahead forecasting</span>
|
||||
<span class="sd"> :param time_to: number of steps ahead to forecast</span>
|
||||
<span class="sd"> :param interpol: Fill space between distribution plots</span>
|
||||
<span class="sd"> :param save: Save the picture on file</span>
|
||||
<span class="sd"> :param file: Filename to save the picture</span>
|
||||
<span class="sd"> :param tam: Size of the picture</span>
|
||||
<span class="sd"> :param resolution:</span>
|
||||
<span class="sd"> :param cmap: Color map to be used on distribution plot</span>
|
||||
<span class="sd"> :param option: Distribution type to be passed for models</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="n">tam</span><span class="p">)</span>
|
||||
<span class="n">ax</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">add_subplot</span><span class="p">(</span><span class="mi">111</span><span class="p">)</span>
|
||||
|
||||
<span class="n">cm</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">get_cmap</span><span class="p">(</span><span class="n">cmap</span><span class="p">)</span>
|
||||
<span class="n">cNorm</span> <span class="o">=</span> <span class="n">pltcolors</span><span class="o">.</span><span class="n">Normalize</span><span class="p">(</span><span class="n">vmin</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">scalarMap</span> <span class="o">=</span> <span class="n">cmx</span><span class="o">.</span><span class="n">ScalarMappable</span><span class="p">(</span><span class="n">norm</span><span class="o">=</span><span class="n">cNorm</span><span class="p">,</span> <span class="n">cmap</span><span class="o">=</span><span class="n">cm</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">resolution</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">resolution</span> <span class="o">=</span> <span class="p">(</span><span class="nb">max</span><span class="p">(</span><span class="n">original</span><span class="p">)</span> <span class="o">-</span> <span class="nb">min</span><span class="p">(</span><span class="n">original</span><span class="p">))</span> <span class="o">/</span> <span class="mi">100</span>
|
||||
|
||||
<span class="n">mi</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">ma</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">count</span><span class="p">,</span> <span class="n">fts</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">models</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">fts</span><span class="o">.</span><span class="n">has_probability_forecasting</span> <span class="ow">and</span> <span class="n">distributions</span><span class="p">[</span><span class="n">count</span><span class="p">]:</span>
|
||||
<span class="n">density</span> <span class="o">=</span> <span class="n">fts</span><span class="o">.</span><span class="n">forecast_ahead_distribution</span><span class="p">(</span><span class="n">original</span><span class="p">[</span><span class="n">time_from</span> <span class="o">-</span> <span class="n">fts</span><span class="o">.</span><span class="n">order</span><span class="p">:</span><span class="n">time_from</span><span class="p">],</span> <span class="n">time_to</span><span class="p">,</span>
|
||||
<span class="n">resolution</span><span class="o">=</span><span class="n">resolution</span><span class="p">)</span>
|
||||
|
||||
<span class="c1">#plot_density_scatter(ax, cmap, density, fig, resolution, time_from, time_to)</span>
|
||||
<span class="n">plot_density_rectange</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">cm</span><span class="p">,</span> <span class="n">density</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">resolution</span><span class="p">,</span> <span class="n">time_from</span><span class="p">,</span> <span class="n">time_to</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">fts</span><span class="o">.</span><span class="n">has_interval_forecasting</span> <span class="ow">and</span> <span class="n">intervals</span><span class="p">:</span>
|
||||
<span class="n">forecasts</span> <span class="o">=</span> <span class="n">fts</span><span class="o">.</span><span class="n">forecast_ahead_interval</span><span class="p">(</span><span class="n">original</span><span class="p">[</span><span class="n">time_from</span> <span class="o">-</span> <span class="n">fts</span><span class="o">.</span><span class="n">order</span><span class="p">:</span><span class="n">time_from</span><span class="p">],</span> <span class="n">time_to</span><span class="p">)</span>
|
||||
<span class="n">lower</span> <span class="o">=</span> <span class="p">[</span><span class="n">kk</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">forecasts</span><span class="p">]</span>
|
||||
<span class="n">upper</span> <span class="o">=</span> <span class="p">[</span><span class="n">kk</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">forecasts</span><span class="p">]</span>
|
||||
<span class="n">mi</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">min</span><span class="p">(</span><span class="n">lower</span><span class="p">))</span>
|
||||
<span class="n">ma</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">max</span><span class="p">(</span><span class="n">upper</span><span class="p">))</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">time_from</span> <span class="o">-</span> <span class="n">fts</span><span class="o">.</span><span class="n">order</span><span class="p">):</span>
|
||||
<span class="n">lower</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">upper</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">lower</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">count</span><span class="p">],</span> <span class="n">label</span><span class="o">=</span><span class="n">fts</span><span class="o">.</span><span class="n">shortname</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">upper</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">count</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="o">*</span><span class="mf">1.5</span><span class="p">)</span>
|
||||
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">original</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">'black'</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">"Original"</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="o">*</span><span class="mf">1.5</span><span class="p">)</span>
|
||||
<span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">get_legend_handles_labels</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="kc">True</span> <span class="ow">in</span> <span class="n">distributions</span><span class="p">:</span>
|
||||
<span class="n">lgd</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span><span class="p">,</span> <span class="n">loc</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">lgd</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span><span class="p">,</span> <span class="n">loc</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">bbox_to_anchor</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
|
||||
<span class="n">_mi</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">mi</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">_mi</span> <span class="o"><</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">_mi</span> <span class="o">*=</span> <span class="mf">1.1</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">_mi</span> <span class="o">*=</span> <span class="mf">0.9</span>
|
||||
<span class="n">_ma</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">ma</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">_ma</span> <span class="o"><</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">_ma</span> <span class="o">*=</span> <span class="mf">0.9</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">_ma</span> <span class="o">*=</span> <span class="mf">1.1</span>
|
||||
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">([</span><span class="n">_mi</span><span class="p">,</span> <span class="n">_ma</span><span class="p">])</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'F(T)'</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'T'</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">original</span><span class="p">)])</span>
|
||||
|
||||
<span class="n">show_and_save_image</span><span class="p">(</span><span class="n">fig</span><span class="p">,</span> <span class="n">file</span><span class="p">,</span> <span class="n">save</span><span class="p">,</span> <span class="n">lgd</span><span class="o">=</span><span class="n">lgd</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_density_rectange"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Util.plot_density_rectange">[docs]</a><span class="k">def</span> <span class="nf">plot_density_rectange</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">cmap</span><span class="p">,</span> <span class="n">density</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">resolution</span><span class="p">,</span> <span class="n">time_from</span><span class="p">,</span> <span class="n">time_to</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Auxiliar function to plot_compared_intervals_ahead</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib.patches</span> <span class="k">import</span> <span class="n">Rectangle</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib.collections</span> <span class="k">import</span> <span class="n">PatchCollection</span>
|
||||
<span class="n">patches</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">colors</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">density</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">density</span><span class="o">.</span><span class="n">columns</span><span class="p">:</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="n">Rectangle</span><span class="p">((</span><span class="n">time_from</span> <span class="o">+</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">resolution</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">lw</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="n">patches</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
|
||||
<span class="n">colors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">density</span><span class="p">[</span><span class="n">y</span><span class="p">][</span><span class="n">x</span><span class="p">]</span><span class="o">*</span><span class="mi">5</span><span class="p">)</span>
|
||||
<span class="n">pc</span> <span class="o">=</span> <span class="n">PatchCollection</span><span class="p">(</span><span class="n">patches</span><span class="o">=</span><span class="n">patches</span><span class="p">,</span> <span class="n">match_original</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_clim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_cmap</span><span class="p">(</span><span class="n">cmap</span><span class="p">)</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_array</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">colors</span><span class="p">))</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">add_collection</span><span class="p">(</span><span class="n">pc</span><span class="p">)</span>
|
||||
<span class="n">cb</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">colorbar</span><span class="p">(</span><span class="n">pc</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>
|
||||
<span class="n">cb</span><span class="o">.</span><span class="n">set_label</span><span class="p">(</span><span class="s1">'Density'</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_probability_distributions"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Util.plot_probability_distributions">[docs]</a><span class="k">def</span> <span class="nf">plot_probability_distributions</span><span class="p">(</span><span class="n">pmfs</span><span class="p">,</span> <span class="n">lcolors</span><span class="p">,</span> <span class="n">tam</span><span class="o">=</span><span class="p">[</span><span class="mi">15</span><span class="p">,</span> <span class="mi">7</span><span class="p">]):</span>
|
||||
<span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="n">tam</span><span class="p">)</span>
|
||||
<span class="n">ax</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">add_subplot</span><span class="p">(</span><span class="mi">111</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">m</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">pmfs</span><span class="p">,</span><span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="n">m</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">lcolors</span><span class="p">[</span><span class="n">k</span><span class="p">])</span>
|
||||
|
||||
<span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span> <span class="o">=</span> <span class="n">ax</span><span class="o">.</span><span class="n">get_legend_handles_labels</span><span class="p">()</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">handles0</span><span class="p">,</span> <span class="n">labels0</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="plot_distribution"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Util.plot_distribution">[docs]</a><span class="k">def</span> <span class="nf">plot_distribution</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">cmap</span><span class="p">,</span> <span class="n">probabilitydist</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">time_from</span><span class="p">,</span> <span class="n">reference_data</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> Plot forecasted ProbabilityDistribution objects on a matplotlib axis</span>
|
||||
|
||||
<span class="sd"> :param ax: matplotlib axis</span>
|
||||
<span class="sd"> :param cmap: matplotlib colormap name</span>
|
||||
<span class="sd"> :param probabilitydist: list of ProbabilityDistribution objects</span>
|
||||
<span class="sd"> :param fig: matplotlib figure</span>
|
||||
<span class="sd"> :param time_from: starting time (on x axis) to begin the plots</span>
|
||||
<span class="sd"> :param reference_data:</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib.patches</span> <span class="k">import</span> <span class="n">Rectangle</span>
|
||||
<span class="kn">from</span> <span class="nn">matplotlib.collections</span> <span class="k">import</span> <span class="n">PatchCollection</span>
|
||||
<span class="n">patches</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">colors</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">probabilitydist</span><span class="p">):</span>
|
||||
<span class="n">disp</span> <span class="o">=</span> <span class="mf">0.0</span>
|
||||
<span class="k">if</span> <span class="n">reference_data</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">disp</span> <span class="o">=</span> <span class="n">reference_data</span><span class="p">[</span><span class="n">time_from</span><span class="o">+</span><span class="n">ct</span><span class="p">]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">dt</span><span class="o">.</span><span class="n">bins</span><span class="p">:</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="n">Rectangle</span><span class="p">((</span><span class="n">time_from</span><span class="o">+</span><span class="n">ct</span><span class="p">,</span> <span class="n">y</span><span class="o">+</span><span class="n">disp</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">resolution</span><span class="p">,</span> <span class="n">fill</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">lw</span> <span class="o">=</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="n">patches</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
|
||||
<span class="n">colors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dt</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="n">y</span><span class="p">))</span>
|
||||
<span class="n">scale</span> <span class="o">=</span> <span class="n">Transformations</span><span class="o">.</span><span class="n">Scale</span><span class="p">()</span>
|
||||
<span class="n">colors</span> <span class="o">=</span> <span class="n">scale</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">colors</span><span class="p">)</span>
|
||||
<span class="n">pc</span> <span class="o">=</span> <span class="n">PatchCollection</span><span class="p">(</span><span class="n">patches</span><span class="o">=</span><span class="n">patches</span><span class="p">,</span> <span class="n">match_original</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_clim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_cmap</span><span class="p">(</span><span class="n">cmap</span><span class="p">)</span>
|
||||
<span class="n">pc</span><span class="o">.</span><span class="n">set_array</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">colors</span><span class="p">))</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">add_collection</span><span class="p">(</span><span class="n">pc</span><span class="p">)</span>
|
||||
<span class="n">cb</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">colorbar</span><span class="p">(</span><span class="n">pc</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>
|
||||
<span class="n">cb</span><span class="o">.</span><span class="n">set_label</span><span class="p">(</span><span class="s1">'Density'</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_interval"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Util.plot_interval">[docs]</a><span class="k">def</span> <span class="nf">plot_interval</span><span class="p">(</span><span class="n">axis</span><span class="p">,</span> <span class="n">intervals</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">'red'</span><span class="p">,</span> <span class="n">typeonlegend</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">ls</span><span class="o">=</span><span class="s1">'-'</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> Plot forecasted intervals on matplotlib</span>
|
||||
|
||||
<span class="sd"> :param axis: matplotlib axis</span>
|
||||
<span class="sd"> :param intervals: list of forecasted intervals</span>
|
||||
<span class="sd"> :param order: order of the model that create the forecasts</span>
|
||||
<span class="sd"> :param label: figure label</span>
|
||||
<span class="sd"> :param color: matplotlib color name</span>
|
||||
<span class="sd"> :param typeonlegend:</span>
|
||||
<span class="sd"> :param ls: matplotlib line style</span>
|
||||
<span class="sd"> :param linewidth: matplotlib width</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="n">lower</span> <span class="o">=</span> <span class="p">[</span><span class="n">kk</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">intervals</span><span class="p">]</span>
|
||||
<span class="n">upper</span> <span class="o">=</span> <span class="p">[</span><span class="n">kk</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">intervals</span><span class="p">]</span>
|
||||
<span class="n">mi</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">lower</span><span class="p">)</span> <span class="o">*</span> <span class="mf">0.95</span>
|
||||
<span class="n">ma</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">upper</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1.05</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">order</span><span class="p">):</span>
|
||||
<span class="n">lower</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">upper</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">typeonlegend</span><span class="p">:</span> <span class="n">label</span> <span class="o">+=</span> <span class="s2">" (Interval)"</span>
|
||||
<span class="n">axis</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">lower</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">ls</span><span class="o">=</span><span class="n">ls</span><span class="p">,</span><span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="p">)</span>
|
||||
<span class="n">axis</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">upper</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">,</span> <span class="n">ls</span><span class="o">=</span><span class="n">ls</span><span class="p">,</span><span class="n">linewidth</span><span class="o">=</span><span class="n">linewidth</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">mi</span><span class="p">,</span> <span class="n">ma</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="plot_rules"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Util.plot_rules">[docs]</a><span class="k">def</span> <span class="nf">plot_rules</span><span class="p">(</span><span class="n">model</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">[</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">],</span> <span class="n">axis</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">rules_by_axis</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> Plot the FLRG rules of a FTS model on a matplotlib axis</span>
|
||||
|
||||
<span class="sd"> :param model: FTS model</span>
|
||||
<span class="sd"> :param size: figure size</span>
|
||||
<span class="sd"> :param axis: matplotlib axis</span>
|
||||
<span class="sd"> :param rules_by_axis: number of rules plotted by column</span>
|
||||
<span class="sd"> :param columns: number of columns</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="k">if</span> <span class="n">axis</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">rules_by_axis</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">rows</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="k">elif</span> <span class="n">axis</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">rules_by_axis</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
|
@ -373,7 +373,7 @@
|
||||
<div class="viewcode-block" id="random_walk"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.random_walk">[docs]</a><span class="k">def</span> <span class="nf">random_walk</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="mi">500</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s1">'gaussian'</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Simple random walk</span>
|
||||
<span class="sd"> </span>
|
||||
|
||||
<span class="sd"> :param n: number of samples</span>
|
||||
<span class="sd"> :param type: 'gaussian' or 'uniform'</span>
|
||||
<span class="sd"> :return:</span>
|
||||
|
@ -117,10 +117,9 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">alpha</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alpha"</span><span class="p">,</span> <span class="mf">0.05</span><span class="p">)</span>
|
||||
<span class="sd">"""The quantiles """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">point_method</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'point_method'</span><span class="p">,</span> <span class="s1">'mean'</span><span class="p">)</span>
|
||||
<span class="sd">"""The method used to mix the several model's forecasts into a unique point forecast. Options: mean, median, quantile"""</span>
|
||||
<span class="sd">"""The method used to mix the several model's forecasts into a unique point forecast. Options: mean, median, quantile, exponential"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">interval_method</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'interval_method'</span><span class="p">,</span> <span class="s1">'quantile'</span><span class="p">)</span>
|
||||
<span class="sd">"""The method used to mix the several model's forecasts into a interval forecast. Options: quantile, extremum, normal"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">order</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
|
||||
<div class="viewcode-block" id="EnsembleFTS.append_model"><a class="viewcode-back" href="../../../../pyFTS.models.ensemble.html#pyFTS.models.ensemble.ensemble.EnsembleFTS.append_model">[docs]</a> <span class="k">def</span> <span class="nf">append_model</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">model</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
@ -137,8 +136,12 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">is_multivariate</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">model</span><span class="o">.</span><span class="n">has_seasonality</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">has_seasonality</span> <span class="o">=</span> <span class="kc">True</span></div>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">has_seasonality</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">model</span><span class="o">.</span><span class="n">original_min</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">original_min</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">original_min</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">original_min</span>
|
||||
<span class="k">elif</span> <span class="n">model</span><span class="o">.</span><span class="n">original_max</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">original_max</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">original_max</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">original_max</span></div>
|
||||
|
||||
<div class="viewcode-block" id="EnsembleFTS.train"><a class="viewcode-back" href="../../../../pyFTS.models.ensemble.html#pyFTS.models.ensemble.ensemble.EnsembleFTS.train">[docs]</a> <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
@ -154,9 +157,9 @@
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indexer</span><span class="o">.</span><span class="n">get_data</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
|
||||
<span class="n">sample</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="o">-</span><span class="n">model</span><span class="o">.</span><span class="n">order</span><span class="p">:]</span>
|
||||
<span class="n">forecast</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">forecast</span><span class="p">(</span><span class="n">sample</span><span class="p">)</span>
|
||||
<span class="n">forecast</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">sample</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">forecast</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">))</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">forecast</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">forecast</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">forecast</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
|
||||
<span class="n">forecast</span> <span class="o">=</span> <span class="n">forecast</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">forecast</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">))</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">forecast</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">forecast</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nan</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">forecast</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
@ -173,6 +176,13 @@
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">point_method</span> <span class="o">==</span> <span class="s1">'quantile'</span><span class="p">:</span>
|
||||
<span class="n">alpha</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"alpha"</span><span class="p">,</span><span class="mf">0.05</span><span class="p">)</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">percentile</span><span class="p">(</span><span class="n">forecasts</span><span class="p">,</span> <span class="n">alpha</span><span class="o">*</span><span class="mi">100</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">point_method</span> <span class="o">==</span> <span class="s1">'exponential'</span><span class="p">:</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">l</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">forecasts</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">w</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="p">(</span><span class="n">l</span> <span class="o">-</span> <span class="n">k</span><span class="p">))</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">l</span><span class="p">)])</span>
|
||||
<span class="n">w</span> <span class="o">=</span> <span class="n">w</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">w</span><span class="p">)</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">([</span><span class="n">w</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">*</span> <span class="n">forecasts</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">l</span><span class="p">)])</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
19
docs/build/html/_modules/pyFTS/models/hofts.html
vendored
19
docs/build/html/_modules/pyFTS/models/hofts.html
vendored
@ -140,8 +140,23 @@
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">w</span></div>
|
||||
|
||||
<div class="viewcode-block" id="WeightedHighOrderFLRG.get_midpoint"><a class="viewcode-back" href="../../../pyFTS.models.html#pyFTS.models.hofts.WeightedHighOrderFLRG.get_midpoint">[docs]</a> <span class="k">def</span> <span class="nf">get_midpoint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="n">mp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">c</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="k">return</span> <span class="n">mp</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weights</span><span class="p">())</span></div>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">mp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">c</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span> <span class="o">=</span> <span class="n">mp</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weights</span><span class="p">())</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span></div>
|
||||
|
||||
<div class="viewcode-block" id="WeightedHighOrderFLRG.get_lower"><a class="viewcode-back" href="../../../pyFTS.models.html#pyFTS.models.hofts.WeightedHighOrderFLRG.get_lower">[docs]</a> <span class="k">def</span> <span class="nf">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">lw</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="n">lw</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weights</span><span class="p">())</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span></div>
|
||||
|
||||
<div class="viewcode-block" id="WeightedHighOrderFLRG.get_upper"><a class="viewcode-back" href="../../../pyFTS.models.html#pyFTS.models.hofts.WeightedHighOrderFLRG.get_upper">[docs]</a> <span class="k">def</span> <span class="nf">get_upper</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">up</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="n">up</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weights</span><span class="p">())</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">_str</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
|
@ -87,7 +87,7 @@
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models</span> <span class="k">import</span> <span class="n">hofts</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="IntervalFTS"><a class="viewcode-back" href="../../../pyFTS.models.html#pyFTS.models.ifts.IntervalFTS">[docs]</a><span class="k">class</span> <span class="nc">IntervalFTS</span><span class="p">(</span><span class="n">hofts</span><span class="o">.</span><span class="n">HighOrderFTS</span><span class="p">):</span>
|
||||
<div class="viewcode-block" id="IntervalFTS"><a class="viewcode-back" href="../../../pyFTS.models.html#pyFTS.models.ifts.IntervalFTS">[docs]</a><span class="k">class</span> <span class="nc">IntervalFTS</span><span class="p">(</span><span class="n">hofts</span><span class="o">.</span><span class="n">WeightedHighOrderFTS</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> High Order Interval Fuzzy Time Series</span>
|
||||
<span class="sd"> """</span>
|
||||
@ -117,9 +117,9 @@
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">flrg</span><span class="o">.</span><span class="n">LHS</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">flrg</span><span class="o">.</span><span class="n">get_key</span><span class="p">()</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">flrgs</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">flrgs</span><span class="p">[</span><span class="n">flrg</span><span class="o">.</span><span class="n">get_key</span><span class="p">()]</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="n">tmp</span><span class="o">.</span><span class="n">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="n">tmp</span><span class="o">.</span><span class="n">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">flrg</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">lower</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">flrg</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">lower</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="IntervalFTS.get_sequence_membership"><a class="viewcode-back" href="../../../pyFTS.models.html#pyFTS.models.ifts.IntervalFTS.get_sequence_membership">[docs]</a> <span class="k">def</span> <span class="nf">get_sequence_membership</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">fuzzySets</span><span class="p">):</span>
|
||||
|
@ -112,9 +112,14 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">batch_size</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'batch_size'</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
|
||||
<span class="sd">"""The batch interval between each retraining"""</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">num_models</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'num_models'</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span>
|
||||
<span class="sd">"""The number of models to hold in the ensemble"""</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">point_method</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'point_method'</span><span class="p">,</span> <span class="s1">'exponential'</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">is_high_order</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">uod_clip</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="c1">#self.max_lag = self.window_length + self.max_lag</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max_lag</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">window_length</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">order</span>
|
||||
|
||||
<div class="viewcode-block" id="IncrementalEnsembleFTS.train"><a class="viewcode-back" href="../../../../pyFTS.models.incremental.html#pyFTS.models.incremental.IncrementalEnsemble.IncrementalEnsembleFTS.train">[docs]</a> <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
|
||||
@ -123,16 +128,9 @@
|
||||
<span class="k">if</span> <span class="n">model</span><span class="o">.</span><span class="n">is_high_order</span><span class="p">:</span>
|
||||
<span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fts_method</span><span class="p">(</span><span class="n">partitioner</span><span class="o">=</span><span class="n">partitioner</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">order</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">fts_params</span><span class="p">)</span>
|
||||
<span class="n">model</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">model</span><span class="p">)</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_point_smoothing</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">forecasts</span><span class="p">):</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="p">)</span>
|
||||
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="p">(</span><span class="n">l</span><span class="o">-</span><span class="n">k</span><span class="p">))</span> <span class="o">*</span> <span class="n">forecasts</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">l</span><span class="p">)])</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">append_model</span><span class="p">(</span><span class="n">model</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">num_models</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="IncrementalEnsembleFTS.forecast"><a class="viewcode-back" href="../../../../pyFTS.models.incremental.html#pyFTS.models.incremental.IncrementalEnsemble.IncrementalEnsembleFTS.forecast">[docs]</a> <span class="k">def</span> <span class="nf">forecast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
@ -143,18 +141,21 @@
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max_lag</span><span class="p">,</span> <span class="n">l</span><span class="p">):</span>
|
||||
|
||||
<span class="n">data_window</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">k</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_lag</span><span class="p">])</span>
|
||||
<span class="n">k2</span> <span class="o">=</span> <span class="n">k</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_lag</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">k</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">window_length</span><span class="p">:</span>
|
||||
<span class="n">data_window</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">k2</span><span class="p">])</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">k2</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">window_length</span><span class="p">:</span>
|
||||
<span class="n">data_window</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">k</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">batch_size</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">k</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">window_length</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">k</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">batch_size</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">k2</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">window_length</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">train</span><span class="p">(</span><span class="n">data_window</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="n">sample</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">k</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_lag</span><span class="p">:</span> <span class="n">k</span><span class="p">]</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_models_forecasts</span><span class="p">(</span><span class="n">sample</span><span class="p">)</span>
|
||||
<span class="n">point</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_point_smoothing</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">point</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">sample</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">k2</span><span class="p">:</span> <span class="n">k</span><span class="p">]</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_models_forecasts</span><span class="p">(</span><span class="n">sample</span><span class="p">)</span>
|
||||
<span class="n">point</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_point</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">point</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div></div>
|
||||
|
||||
|
@ -111,6 +111,7 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">is_high_order</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">uod_clip</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max_lag</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">window_length</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">order</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">is_wrapper</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<div class="viewcode-block" id="Retrainer.train"><a class="viewcode-back" href="../../../../pyFTS.models.incremental.html#pyFTS.models.incremental.TimeVariant.Retrainer.train">[docs]</a> <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitioner</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitioner_method</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">partitioner_params</span><span class="p">)</span>
|
||||
|
@ -96,7 +96,6 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">var</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">var</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">fset</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FLRG.append_rhs"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.append_rhs">[docs]</a> <span class="k">def</span> <span class="nf">append_rhs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fset</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">fset</span><span class="p">)</span></div>
|
||||
|
||||
@ -108,6 +107,18 @@
|
||||
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">mvs</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_lower"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.get_lower">[docs]</a> <span class="k">def</span> <span class="nf">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">rhs</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span> <span class="k">for</span> <span class="n">rhs</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_upper"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.get_upper">[docs]</a> <span class="k">def</span> <span class="nf">get_upper</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">rhs</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span> <span class="k">for</span> <span class="n">rhs</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">_str</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">:</span>
|
||||
|
@ -219,8 +219,9 @@
|
||||
<span class="n">mvs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.</span><span class="p">)</span>
|
||||
<span class="n">mps</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">mvs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">flrgs</span><span class="p">[</span><span class="n">flrg</span><span class="o">.</span><span class="n">get_key</span><span class="p">()]</span><span class="o">.</span><span class="n">get_membership</span><span class="p">(</span><span class="n">data_point</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">))</span>
|
||||
<span class="n">mps</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">flrgs</span><span class="p">[</span><span class="n">flrg</span><span class="o">.</span><span class="n">get_key</span><span class="p">()]</span><span class="o">.</span><span class="n">get_midpoint</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">))</span>
|
||||
<span class="n">_flrg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">flrgs</span><span class="p">[</span><span class="n">flrg</span><span class="o">.</span><span class="n">get_key</span><span class="p">()]</span>
|
||||
<span class="n">mvs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">_flrg</span><span class="o">.</span><span class="n">get_membership</span><span class="p">(</span><span class="n">data_point</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">))</span>
|
||||
<span class="n">mps</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">_flrg</span><span class="o">.</span><span class="n">get_midpoint</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">))</span>
|
||||
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">mvs</span><span class="p">)</span>
|
||||
<span class="n">mp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">mps</span><span class="p">)</span>
|
||||
@ -275,6 +276,49 @@
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MVFTS.forecast_interval"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.mvfts.MVFTS.forecast_interval">[docs]</a> <span class="k">def</span> <span class="nf">forecast_interval</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">apply_transformations</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="n">c</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">for</span> <span class="n">index</span><span class="p">,</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">ndata</span><span class="o">.</span><span class="n">iterrows</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ndata</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">)</span> <span class="k">else</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">ndata</span><span class="p">):</span>
|
||||
<span class="n">data_point</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">format_data</span><span class="p">(</span><span class="n">row</span><span class="p">)</span>
|
||||
<span class="n">flrs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">generate_lhs_flrs</span><span class="p">(</span><span class="n">data_point</span><span class="p">)</span>
|
||||
<span class="n">mvs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">ups</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">los</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">flr</span> <span class="ow">in</span> <span class="n">flrs</span><span class="p">:</span>
|
||||
<span class="n">flrg</span> <span class="o">=</span> <span class="n">mvflrg</span><span class="o">.</span><span class="n">FLRG</span><span class="p">(</span><span class="n">lhs</span><span class="o">=</span><span class="n">flr</span><span class="o">.</span><span class="n">LHS</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">flrg</span><span class="o">.</span><span class="n">get_key</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">flrgs</span><span class="p">:</span>
|
||||
<span class="c1">#Naïve approach is applied when no rules were found</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="n">flrg</span><span class="o">.</span><span class="n">LHS</span><span class="p">:</span>
|
||||
<span class="n">fs</span> <span class="o">=</span> <span class="n">flrg</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
|
||||
<span class="n">fset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fs</span><span class="p">]</span>
|
||||
<span class="n">up</span> <span class="o">=</span> <span class="n">fset</span><span class="o">.</span><span class="n">upper</span>
|
||||
<span class="n">lo</span> <span class="o">=</span> <span class="n">fset</span><span class="o">.</span><span class="n">lower</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">fset</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data_point</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">name</span><span class="p">])</span>
|
||||
<span class="n">mvs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">ups</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">up</span><span class="p">)</span>
|
||||
<span class="n">los</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lo</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">mvs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.</span><span class="p">)</span>
|
||||
<span class="n">ups</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.</span><span class="p">)</span>
|
||||
<span class="n">los</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">_flrg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">flrgs</span><span class="p">[</span><span class="n">flrg</span><span class="o">.</span><span class="n">get_key</span><span class="p">()]</span>
|
||||
<span class="n">mvs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">_flrg</span><span class="o">.</span><span class="n">get_membership</span><span class="p">(</span><span class="n">data_point</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">))</span>
|
||||
<span class="n">ups</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">_flrg</span><span class="o">.</span><span class="n">get_upper</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">))</span>
|
||||
<span class="n">los</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">_flrg</span><span class="o">.</span><span class="n">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">))</span>
|
||||
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">mvs</span><span class="p">)</span>
|
||||
<span class="n">up</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">mv</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">ups</span><span class="p">)</span><span class="o">.</span><span class="n">T</span><span class="p">)</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">lo</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">mv</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">los</span><span class="p">)</span><span class="o">.</span><span class="n">T</span><span class="p">)</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">lo</span><span class="p">,</span> <span class="n">up</span><span class="p">])</span>
|
||||
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">apply_inverse_transformations</span><span class="p">(</span><span class="n">ret</span><span class="p">,</span>
|
||||
<span class="n">params</span><span class="o">=</span><span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">data_label</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="MVFTS.clone_parameters"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.mvfts.MVFTS.clone_parameters">[docs]</a> <span class="k">def</span> <span class="nf">clone_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">model</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">MVFTS</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">clone_parameters</span><span class="p">(</span><span class="n">model</span><span class="p">)</span>
|
||||
|
@ -107,8 +107,23 @@
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">w</span></div>
|
||||
|
||||
<div class="viewcode-block" id="WeightedFLRG.get_midpoint"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_midpoint">[docs]</a> <span class="k">def</span> <span class="nf">get_midpoint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="n">mp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">c</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="k">return</span> <span class="n">mp</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weights</span><span class="p">())</span></div>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">mp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">c</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span> <span class="o">=</span> <span class="n">mp</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weights</span><span class="p">())</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span></div>
|
||||
|
||||
<div class="viewcode-block" id="WeightedFLRG.get_lower"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_lower">[docs]</a> <span class="k">def</span> <span class="nf">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">lw</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="n">lw</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weights</span><span class="p">())</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span></div>
|
||||
|
||||
<div class="viewcode-block" id="WeightedFLRG.get_upper"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_upper">[docs]</a> <span class="k">def</span> <span class="nf">get_upper</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">up</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="n">up</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weights</span><span class="p">())</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span></div>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
|
38
docs/build/html/genindex.html
vendored
38
docs/build/html/genindex.html
vendored
@ -354,8 +354,6 @@
|
||||
<li><a href="pyFTS.models.multivariate.html#pyFTS.models.multivariate.mvfts.MVFTS.clone_parameters">(pyFTS.models.multivariate.mvfts.MVFTS method)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="pyFTS.hyperparam.html#pyFTS.hyperparam.GridSearch.cluster_method">cluster_method() (in module pyFTS.hyperparam.GridSearch)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.multivariate.html#pyFTS.models.multivariate.cmvfts.ClusteredMVFTS">ClusteredMVFTS (class in pyFTS.models.multivariate.cmvfts)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.partitioners.html#pyFTS.partitioners.CMeans.CMeansPartitioner">CMeansPartitioner (class in pyFTS.partitioners.CMeans)</a>
|
||||
@ -445,8 +443,6 @@
|
||||
<li><a href="pyFTS.probabilistic.html#pyFTS.probabilistic.ProbabilityDistribution.ProbabilityDistribution.density">density() (pyFTS.probabilistic.ProbabilityDistribution.ProbabilityDistribution method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.fts.FTS.detail">detail (pyFTS.common.fts.FTS attribute)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.hyperparam.html#pyFTS.hyperparam.GridSearch.dict_individual">dict_individual() (in module pyFTS.hyperparam.GridSearch)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.Transformations.Differential">Differential (class in pyFTS.common.Transformations)</a>
|
||||
</li>
|
||||
@ -480,12 +476,10 @@
|
||||
</li>
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.Util.enumerate2">enumerate2() (in module pyFTS.common.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.hyperparam.html#pyFTS.hyperparam.GridSearch.execute">execute() (in module pyFTS.hyperparam.GridSearch)</a>
|
||||
<li><a href="pyFTS.probabilistic.html#pyFTS.probabilistic.ProbabilityDistribution.ProbabilityDistribution.expected_value">expected_value() (pyFTS.probabilistic.ProbabilityDistribution.ProbabilityDistribution method)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="pyFTS.probabilistic.html#pyFTS.probabilistic.ProbabilityDistribution.ProbabilityDistribution.expected_value">expected_value() (pyFTS.probabilistic.ProbabilityDistribution.ProbabilityDistribution method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.partitioners.html#pyFTS.partitioners.parallel_util.explore_partitioners">explore_partitioners() (in module pyFTS.partitioners.parallel_util)</a>
|
||||
|
||||
<ul>
|
||||
@ -666,6 +660,8 @@
|
||||
<li><a href="pyFTS.models.ensemble.html#pyFTS.models.ensemble.ensemble.EnsembleFTS.forecast_interval">(pyFTS.models.ensemble.ensemble.EnsembleFTS method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.html#pyFTS.models.ifts.IntervalFTS.forecast_interval">(pyFTS.models.ifts.IntervalFTS method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.multivariate.html#pyFTS.models.multivariate.mvfts.MVFTS.forecast_interval">(pyFTS.models.multivariate.mvfts.MVFTS method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.cvfts.ConditionalVarianceFTS.forecast_interval">(pyFTS.models.nonstationary.cvfts.ConditionalVarianceFTS method)</a>
|
||||
</li>
|
||||
@ -971,7 +967,13 @@
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.flrg.FLRG.get_lower">get_lower() (pyFTS.common.flrg.FLRG method)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="pyFTS.models.html#pyFTS.models.hofts.WeightedHighOrderFLRG.get_lower">(pyFTS.models.hofts.WeightedHighOrderFLRG method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.html#pyFTS.models.ifts.IntervalFTS.get_lower">(pyFTS.models.ifts.IntervalFTS method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.get_lower">(pyFTS.models.multivariate.flrg.FLRG method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.multivariate.html#pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_lower">(pyFTS.models.multivariate.wmvfts.WeightedFLRG method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.get_lower">(pyFTS.models.nonstationary.common.FuzzySet method)</a>
|
||||
</li>
|
||||
@ -1065,7 +1067,13 @@
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.flrg.FLRG.get_upper">get_upper() (pyFTS.common.flrg.FLRG method)</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="pyFTS.models.html#pyFTS.models.hofts.WeightedHighOrderFLRG.get_upper">(pyFTS.models.hofts.WeightedHighOrderFLRG method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.html#pyFTS.models.ifts.IntervalFTS.get_upper">(pyFTS.models.ifts.IntervalFTS method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.get_upper">(pyFTS.models.multivariate.flrg.FLRG method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.multivariate.html#pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_upper">(pyFTS.models.multivariate.wmvfts.WeightedFLRG method)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.get_upper">(pyFTS.models.nonstationary.common.FuzzySet method)</a>
|
||||
</li>
|
||||
@ -1359,6 +1367,8 @@
|
||||
<li><a href="pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.flrg.NonStationaryFLRG">NonStationaryFLRG (class in pyFTS.models.nonstationary.flrg)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.nsfts.NonStationaryFTS">NonStationaryFTS (class in pyFTS.models.nonstationary.nsfts)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.models.incremental.html#pyFTS.models.incremental.IncrementalEnsemble.IncrementalEnsembleFTS.num_models">num_models (pyFTS.models.incremental.IncrementalEnsemble.IncrementalEnsembleFTS attribute)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
@ -1470,7 +1480,7 @@
|
||||
<li><a href="pyFTS.probabilistic.html#pyFTS.probabilistic.ProbabilityDistribution.ProbabilityDistribution.plot">(pyFTS.probabilistic.ProbabilityDistribution.ProbabilityDistribution method)</a>
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_compared_intervals_ahead">plot_compared_intervals_ahead() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.Util.plot_compared_intervals_ahead">plot_compared_intervals_ahead() (in module pyFTS.common.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_compared_series">plot_compared_series() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
</li>
|
||||
@ -1482,17 +1492,17 @@
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.Util.plot_dataframe_probabilistic">plot_dataframe_probabilistic() (in module pyFTS.benchmarks.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_density_rectange">plot_density_rectange() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.Util.plot_density_rectange">plot_density_rectange() (in module pyFTS.common.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_distribution">plot_distribution() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.Util.plot_distribution">plot_distribution() (in module pyFTS.common.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_interval">plot_interval() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.Util.plot_interval">plot_interval() (in module pyFTS.common.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.partitioners.html#pyFTS.partitioners.Util.plot_partitioners">plot_partitioners() (in module pyFTS.partitioners.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_point">plot_point() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.plot_probability_distributions">plot_probability_distributions() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
<li><a href="pyFTS.common.html#pyFTS.common.Util.plot_probability_distributions">plot_probability_distributions() (in module pyFTS.common.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.ResidualAnalysis.plot_residuals">plot_residuals() (in module pyFTS.benchmarks.ResidualAnalysis)</a>
|
||||
</li>
|
||||
@ -1559,8 +1569,6 @@
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.Util.process_common_data">process_common_data() (in module pyFTS.benchmarks.Util)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.process_interval_jobs">process_interval_jobs() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.hyperparam.html#pyFTS.hyperparam.GridSearch.process_jobs">process_jobs() (in module pyFTS.hyperparam.GridSearch)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.benchmarks.html#pyFTS.benchmarks.benchmarks.process_point_jobs">process_point_jobs() (in module pyFTS.benchmarks.benchmarks)</a>
|
||||
</li>
|
||||
@ -1667,8 +1675,6 @@
|
||||
<li><a href="pyFTS.distributed.html#module-pyFTS.distributed.spark">pyFTS.distributed.spark (module)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.hyperparam.html#module-pyFTS.hyperparam">pyFTS.hyperparam (module)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.hyperparam.html#module-pyFTS.hyperparam.GridSearch">pyFTS.hyperparam.GridSearch (module)</a>
|
||||
</li>
|
||||
<li><a href="pyFTS.hyperparam.html#module-pyFTS.hyperparam.Util">pyFTS.hyperparam.Util (module)</a>
|
||||
</li>
|
||||
|
BIN
docs/build/html/objects.inv
vendored
BIN
docs/build/html/objects.inv
vendored
Binary file not shown.
5
docs/build/html/py-modindex.html
vendored
5
docs/build/html/py-modindex.html
vendored
@ -325,11 +325,6 @@
|
||||
<td>   
|
||||
<a href="pyFTS.hyperparam.html#module-pyFTS.hyperparam"><code class="xref">pyFTS.hyperparam</code></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>   
|
||||
<a href="pyFTS.hyperparam.html#module-pyFTS.hyperparam.GridSearch"><code class="xref">pyFTS.hyperparam.GridSearch</code></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>   
|
||||
|
53
docs/build/html/pyFTS.benchmarks.html
vendored
53
docs/build/html/pyFTS.benchmarks.html
vendored
@ -189,38 +189,6 @@
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">plotCompared</code><span class="sig-paren">(</span><em>original</em>, <em>forecasts</em>, <em>labels</em>, <em>title</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#plotCompared"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.plotCompared" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.benchmarks.benchmarks.plot_compared_intervals_ahead">
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">plot_compared_intervals_ahead</code><span class="sig-paren">(</span><em>original, models, colors, distributions, time_from, time_to, intervals=True, save=False, file=None, tam=[20, 5], resolution=None, cmap='Blues', linewidth=1.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#plot_compared_intervals_ahead"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.plot_compared_intervals_ahead" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Plot the forecasts of several one step ahead models, by point or by interval</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
|
||||
<li><strong>original</strong> – Original time series data (list)</li>
|
||||
<li><strong>models</strong> – List of models to compare</li>
|
||||
<li><strong>colors</strong> – List of models colors</li>
|
||||
<li><strong>distributions</strong> – True to plot a distribution</li>
|
||||
<li><strong>time_from</strong> – index of data poit to start the ahead forecasting</li>
|
||||
<li><strong>time_to</strong> – number of steps ahead to forecast</li>
|
||||
<li><strong>interpol</strong> – Fill space between distribution plots</li>
|
||||
<li><strong>save</strong> – Save the picture on file</li>
|
||||
<li><strong>file</strong> – Filename to save the picture</li>
|
||||
<li><strong>tam</strong> – Size of the picture</li>
|
||||
<li><strong>resolution</strong> – </li>
|
||||
<li><strong>cmap</strong> – Color map to be used on distribution plot</li>
|
||||
<li><strong>option</strong> – Distribution type to be passed for models</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.benchmarks.benchmarks.plot_compared_series">
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">plot_compared_series</code><span class="sig-paren">(</span><em>original, models, colors, typeonlegend=False, save=False, file=None, tam=[20, 5], points=True, intervals=True, linewidth=1.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#plot_compared_series"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.plot_compared_series" title="Permalink to this definition">¶</a></dt>
|
||||
@ -250,32 +218,11 @@
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.benchmarks.benchmarks.plot_density_rectange">
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">plot_density_rectange</code><span class="sig-paren">(</span><em>ax</em>, <em>cmap</em>, <em>density</em>, <em>fig</em>, <em>resolution</em>, <em>time_from</em>, <em>time_to</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#plot_density_rectange"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.plot_density_rectange" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Auxiliar function to plot_compared_intervals_ahead</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.benchmarks.benchmarks.plot_distribution">
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">plot_distribution</code><span class="sig-paren">(</span><em>ax</em>, <em>cmap</em>, <em>probabilitydist</em>, <em>fig</em>, <em>time_from</em>, <em>reference_data=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#plot_distribution"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.plot_distribution" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.benchmarks.benchmarks.plot_interval">
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">plot_interval</code><span class="sig-paren">(</span><em>axis</em>, <em>intervals</em>, <em>order</em>, <em>label</em>, <em>color='red'</em>, <em>typeonlegend=False</em>, <em>ls='-'</em>, <em>linewidth=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#plot_interval"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.plot_interval" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.benchmarks.benchmarks.plot_point">
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">plot_point</code><span class="sig-paren">(</span><em>axis</em>, <em>points</em>, <em>order</em>, <em>label</em>, <em>color='red'</em>, <em>ls='-'</em>, <em>linewidth=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#plot_point"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.plot_point" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.benchmarks.benchmarks.plot_probability_distributions">
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">plot_probability_distributions</code><span class="sig-paren">(</span><em>pmfs, lcolors, tam=[15, 7]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#plot_probability_distributions"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.plot_probability_distributions" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.benchmarks.benchmarks.print_distribution_statistics">
|
||||
<code class="descclassname">pyFTS.benchmarks.benchmarks.</code><code class="descname">print_distribution_statistics</code><span class="sig-paren">(</span><em>original</em>, <em>models</em>, <em>steps</em>, <em>resolution</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/benchmarks/benchmarks.html#print_distribution_statistics"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.benchmarks.benchmarks.print_distribution_statistics" title="Permalink to this definition">¶</a></dt>
|
||||
|
116
docs/build/html/pyFTS.common.html
vendored
116
docs/build/html/pyFTS.common.html
vendored
@ -1253,10 +1253,124 @@ bisect but with a simpler API and support for key functions.</p>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.common.Util.plot_compared_intervals_ahead">
|
||||
<code class="descclassname">pyFTS.common.Util.</code><code class="descname">plot_compared_intervals_ahead</code><span class="sig-paren">(</span><em>original, models, colors, distributions, time_from, time_to, intervals=True, save=False, file=None, tam=[20, 5], resolution=None, cmap='Blues', linewidth=1.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/common/Util.html#plot_compared_intervals_ahead"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.common.Util.plot_compared_intervals_ahead" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Plot the forecasts of several one step ahead models, by point or by interval</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
|
||||
<li><strong>original</strong> – Original time series data (list)</li>
|
||||
<li><strong>models</strong> – List of models to compare</li>
|
||||
<li><strong>colors</strong> – List of models colors</li>
|
||||
<li><strong>distributions</strong> – True to plot a distribution</li>
|
||||
<li><strong>time_from</strong> – index of data poit to start the ahead forecasting</li>
|
||||
<li><strong>time_to</strong> – number of steps ahead to forecast</li>
|
||||
<li><strong>interpol</strong> – Fill space between distribution plots</li>
|
||||
<li><strong>save</strong> – Save the picture on file</li>
|
||||
<li><strong>file</strong> – Filename to save the picture</li>
|
||||
<li><strong>tam</strong> – Size of the picture</li>
|
||||
<li><strong>resolution</strong> – </li>
|
||||
<li><strong>cmap</strong> – Color map to be used on distribution plot</li>
|
||||
<li><strong>option</strong> – Distribution type to be passed for models</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.common.Util.plot_density_rectange">
|
||||
<code class="descclassname">pyFTS.common.Util.</code><code class="descname">plot_density_rectange</code><span class="sig-paren">(</span><em>ax</em>, <em>cmap</em>, <em>density</em>, <em>fig</em>, <em>resolution</em>, <em>time_from</em>, <em>time_to</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/common/Util.html#plot_density_rectange"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.common.Util.plot_density_rectange" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Auxiliar function to plot_compared_intervals_ahead</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.common.Util.plot_distribution">
|
||||
<code class="descclassname">pyFTS.common.Util.</code><code class="descname">plot_distribution</code><span class="sig-paren">(</span><em>ax</em>, <em>cmap</em>, <em>probabilitydist</em>, <em>fig</em>, <em>time_from</em>, <em>reference_data=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/common/Util.html#plot_distribution"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.common.Util.plot_distribution" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Plot forecasted ProbabilityDistribution objects on a matplotlib axis</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
|
||||
<li><strong>ax</strong> – matplotlib axis</li>
|
||||
<li><strong>cmap</strong> – matplotlib colormap name</li>
|
||||
<li><strong>probabilitydist</strong> – list of ProbabilityDistribution objects</li>
|
||||
<li><strong>fig</strong> – matplotlib figure</li>
|
||||
<li><strong>time_from</strong> – starting time (on x axis) to begin the plots</li>
|
||||
<li><strong>reference_data</strong> – </li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.common.Util.plot_interval">
|
||||
<code class="descclassname">pyFTS.common.Util.</code><code class="descname">plot_interval</code><span class="sig-paren">(</span><em>axis</em>, <em>intervals</em>, <em>order</em>, <em>label</em>, <em>color='red'</em>, <em>typeonlegend=False</em>, <em>ls='-'</em>, <em>linewidth=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/common/Util.html#plot_interval"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.common.Util.plot_interval" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Plot forecasted intervals on matplotlib</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
|
||||
<li><strong>axis</strong> – matplotlib axis</li>
|
||||
<li><strong>intervals</strong> – list of forecasted intervals</li>
|
||||
<li><strong>order</strong> – order of the model that create the forecasts</li>
|
||||
<li><strong>label</strong> – figure label</li>
|
||||
<li><strong>color</strong> – matplotlib color name</li>
|
||||
<li><strong>typeonlegend</strong> – </li>
|
||||
<li><strong>ls</strong> – matplotlib line style</li>
|
||||
<li><strong>linewidth</strong> – matplotlib width</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.common.Util.plot_probability_distributions">
|
||||
<code class="descclassname">pyFTS.common.Util.</code><code class="descname">plot_probability_distributions</code><span class="sig-paren">(</span><em>pmfs, lcolors, tam=[15, 7]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/common/Util.html#plot_probability_distributions"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.common.Util.plot_probability_distributions" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.common.Util.plot_rules">
|
||||
<code class="descclassname">pyFTS.common.Util.</code><code class="descname">plot_rules</code><span class="sig-paren">(</span><em>model, size=[5, 5], axis=None, rules_by_axis=None, columns=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/common/Util.html#plot_rules"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.common.Util.plot_rules" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
<dd><p>Plot the FLRG rules of a FTS model on a matplotlib axis</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
|
||||
<li><strong>model</strong> – FTS model</li>
|
||||
<li><strong>size</strong> – figure size</li>
|
||||
<li><strong>axis</strong> – matplotlib axis</li>
|
||||
<li><strong>rules_by_axis</strong> – number of rules plotted by column</li>
|
||||
<li><strong>columns</strong> – number of columns</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.common.Util.show_and_save_image">
|
||||
|
2
docs/build/html/pyFTS.html
vendored
2
docs/build/html/pyFTS.html
vendored
@ -176,7 +176,7 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="pyFTS.hyperparam.html#module-pyFTS.hyperparam">Module contents</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="pyFTS.hyperparam.html#submodules">Submodules</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="pyFTS.hyperparam.html#module-pyFTS.hyperparam.Util">pyFTS.hyperparam.Util module</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="pyFTS.hyperparam.html#module-pyFTS.hyperparam.GridSearch">pyFTS.hyperparam.GridSearch module</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="pyFTS.hyperparam.html#pyfts-hyperparam-gridsearch-module">pyFTS.hyperparam.GridSearch module</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="pyFTS.hyperparam.html#pyfts-hyperparam-evolutionary-module">pyFTS.hyperparam.Evolutionary module</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
26
docs/build/html/pyFTS.hyperparam.html
vendored
26
docs/build/html/pyFTS.hyperparam.html
vendored
@ -66,7 +66,7 @@
|
||||
<li><a class="reference internal" href="#module-pyFTS.hyperparam">Module contents</a></li>
|
||||
<li><a class="reference internal" href="#submodules">Submodules</a></li>
|
||||
<li><a class="reference internal" href="#module-pyFTS.hyperparam.Util">pyFTS.hyperparam.Util module</a></li>
|
||||
<li><a class="reference internal" href="#module-pyFTS.hyperparam.GridSearch">pyFTS.hyperparam.GridSearch module</a></li>
|
||||
<li><a class="reference internal" href="#pyfts-hyperparam-gridsearch-module">pyFTS.hyperparam.GridSearch module</a></li>
|
||||
<li><a class="reference internal" href="#pyfts-hyperparam-evolutionary-module">pyFTS.hyperparam.Evolutionary module</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@ -183,28 +183,8 @@ Value: the measure value</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-pyFTS.hyperparam.GridSearch">
|
||||
<span id="pyfts-hyperparam-gridsearch-module"></span><h2>pyFTS.hyperparam.GridSearch module<a class="headerlink" href="#module-pyFTS.hyperparam.GridSearch" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.hyperparam.GridSearch.cluster_method">
|
||||
<code class="descclassname">pyFTS.hyperparam.GridSearch.</code><code class="descname">cluster_method</code><span class="sig-paren">(</span><em>individual</em>, <em>train</em>, <em>test</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/hyperparam/GridSearch.html#cluster_method"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.hyperparam.GridSearch.cluster_method" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.hyperparam.GridSearch.dict_individual">
|
||||
<code class="descclassname">pyFTS.hyperparam.GridSearch.</code><code class="descname">dict_individual</code><span class="sig-paren">(</span><em>mf</em>, <em>partitioner</em>, <em>partitions</em>, <em>order</em>, <em>lags</em>, <em>alpha_cut</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/hyperparam/GridSearch.html#dict_individual"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.hyperparam.GridSearch.dict_individual" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.hyperparam.GridSearch.execute">
|
||||
<code class="descclassname">pyFTS.hyperparam.GridSearch.</code><code class="descname">execute</code><span class="sig-paren">(</span><em>hyperparams</em>, <em>datasetname</em>, <em>train</em>, <em>test</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/hyperparam/GridSearch.html#execute"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.hyperparam.GridSearch.execute" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="function">
|
||||
<dt id="pyFTS.hyperparam.GridSearch.process_jobs">
|
||||
<code class="descclassname">pyFTS.hyperparam.GridSearch.</code><code class="descname">process_jobs</code><span class="sig-paren">(</span><em>jobs</em>, <em>datasetname</em>, <em>conn</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/hyperparam/GridSearch.html#process_jobs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.hyperparam.GridSearch.process_jobs" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<div class="section" id="pyfts-hyperparam-gridsearch-module">
|
||||
<h2>pyFTS.hyperparam.GridSearch module<a class="headerlink" href="#pyfts-hyperparam-gridsearch-module" title="Permalink to this headline">¶</a></h2>
|
||||
</div>
|
||||
<div class="section" id="pyfts-hyperparam-evolutionary-module">
|
||||
<h2>pyFTS.hyperparam.Evolutionary module<a class="headerlink" href="#pyfts-hyperparam-evolutionary-module" title="Permalink to this headline">¶</a></h2>
|
||||
|
2
docs/build/html/pyFTS.models.ensemble.html
vendored
2
docs/build/html/pyFTS.models.ensemble.html
vendored
@ -319,7 +319,7 @@ XIII Brazilian Congress on Computational Intelligence, 2017. Rio de Janeiro, Bra
|
||||
<dl class="attribute">
|
||||
<dt id="pyFTS.models.ensemble.ensemble.EnsembleFTS.point_method">
|
||||
<code class="descname">point_method</code><em class="property"> = None</em><a class="headerlink" href="#pyFTS.models.ensemble.ensemble.EnsembleFTS.point_method" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The method used to mix the several model’s forecasts into a unique point forecast. Options: mean, median, quantile</p>
|
||||
<dd><p>The method used to mix the several model’s forecasts into a unique point forecast. Options: mean, median, quantile, exponential</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
|
34
docs/build/html/pyFTS.models.html
vendored
34
docs/build/html/pyFTS.models.html
vendored
@ -528,6 +528,22 @@ using Fuzzy Time Series. 2017 IEEE International Conference on Fuzzy Systems. DO
|
||||
<code class="descname">append_rhs</code><span class="sig-paren">(</span><em>fset</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/hofts.html#WeightedHighOrderFLRG.append_rhs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.hofts.WeightedHighOrderFLRG.append_rhs" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.hofts.WeightedHighOrderFLRG.get_lower">
|
||||
<code class="descname">get_lower</code><span class="sig-paren">(</span><em>sets</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/hofts.html#WeightedHighOrderFLRG.get_lower"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.hofts.WeightedHighOrderFLRG.get_lower" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the lower bound value for the RHS fuzzy sets</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>sets</strong> – fuzzy sets</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">lower bound value</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.hofts.WeightedHighOrderFLRG.get_midpoint">
|
||||
<code class="descname">get_midpoint</code><span class="sig-paren">(</span><em>sets</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/hofts.html#WeightedHighOrderFLRG.get_midpoint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.hofts.WeightedHighOrderFLRG.get_midpoint" title="Permalink to this definition">¶</a></dt>
|
||||
@ -544,6 +560,22 @@ using Fuzzy Time Series. 2017 IEEE International Conference on Fuzzy Systems. DO
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.hofts.WeightedHighOrderFLRG.get_upper">
|
||||
<code class="descname">get_upper</code><span class="sig-paren">(</span><em>sets</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/hofts.html#WeightedHighOrderFLRG.get_upper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.hofts.WeightedHighOrderFLRG.get_upper" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the upper bound value for the RHS fuzzy sets</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>sets</strong> – fuzzy sets</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">upper bound value</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.hofts.WeightedHighOrderFLRG.weights">
|
||||
<code class="descname">weights</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/hofts.html#WeightedHighOrderFLRG.weights"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.hofts.WeightedHighOrderFLRG.weights" title="Permalink to this definition">¶</a></dt>
|
||||
@ -628,7 +660,7 @@ In: Computational Intelligence (SSCI), 2016 IEEE Symposium Series on. IEEE, 2016
|
||||
<dl class="class">
|
||||
<dt id="pyFTS.models.ifts.IntervalFTS">
|
||||
<em class="property">class </em><code class="descclassname">pyFTS.models.ifts.</code><code class="descname">IntervalFTS</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/ifts.html#IntervalFTS"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.ifts.IntervalFTS" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Bases: <a class="reference internal" href="#pyFTS.models.hofts.HighOrderFTS" title="pyFTS.models.hofts.HighOrderFTS"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyFTS.models.hofts.HighOrderFTS</span></code></a></p>
|
||||
<dd><p>Bases: <a class="reference internal" href="#pyFTS.models.hofts.WeightedHighOrderFTS" title="pyFTS.models.hofts.WeightedHighOrderFTS"><code class="xref py py-class docutils literal notranslate"><span class="pre">pyFTS.models.hofts.WeightedHighOrderFTS</span></code></a></p>
|
||||
<p>High Order Interval Fuzzy Time Series</p>
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.ifts.IntervalFTS.forecast_interval">
|
||||
|
@ -265,6 +265,12 @@
|
||||
<dd><p>The FTS method specific parameters</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
<dt id="pyFTS.models.incremental.IncrementalEnsemble.IncrementalEnsembleFTS.num_models">
|
||||
<code class="descname">num_models</code><em class="property"> = None</em><a class="headerlink" href="#pyFTS.models.incremental.IncrementalEnsemble.IncrementalEnsembleFTS.num_models" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The number of models to hold in the ensemble</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
<dt id="pyFTS.models.incremental.IncrementalEnsemble.IncrementalEnsembleFTS.partitioner_method">
|
||||
<code class="descname">partitioner_method</code><em class="property"> = None</em><a class="headerlink" href="#pyFTS.models.incremental.IncrementalEnsemble.IncrementalEnsembleFTS.partitioner_method" title="Permalink to this definition">¶</a></dt>
|
||||
|
85
docs/build/html/pyFTS.models.multivariate.html
vendored
85
docs/build/html/pyFTS.models.multivariate.html
vendored
@ -294,6 +294,22 @@ transformations and partitioners.</p>
|
||||
<code class="descname">append_rhs</code><span class="sig-paren">(</span><em>fset</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/flrg.html#FLRG.append_rhs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.flrg.FLRG.append_rhs" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.flrg.FLRG.get_lower">
|
||||
<code class="descname">get_lower</code><span class="sig-paren">(</span><em>sets</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/flrg.html#FLRG.get_lower"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.flrg.FLRG.get_lower" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the lower bound value for the RHS fuzzy sets</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>sets</strong> – fuzzy sets</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">lower bound value</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.flrg.FLRG.get_membership">
|
||||
<code class="descname">get_membership</code><span class="sig-paren">(</span><em>data</em>, <em>variables</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/flrg.html#FLRG.get_membership"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.flrg.FLRG.get_membership" title="Permalink to this definition">¶</a></dt>
|
||||
@ -315,6 +331,22 @@ transformations and partitioners.</p>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.flrg.FLRG.get_upper">
|
||||
<code class="descname">get_upper</code><span class="sig-paren">(</span><em>sets</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/flrg.html#FLRG.get_upper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.flrg.FLRG.get_upper" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the upper bound value for the RHS fuzzy sets</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>sets</strong> – fuzzy sets</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">upper bound value</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.flrg.FLRG.set_lhs">
|
||||
<code class="descname">set_lhs</code><span class="sig-paren">(</span><em>var</em>, <em>fset</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/flrg.html#FLRG.set_lhs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.flrg.FLRG.set_lhs" title="Permalink to this definition">¶</a></dt>
|
||||
@ -426,6 +458,27 @@ transformations and partitioners.</p>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.mvfts.MVFTS.forecast_interval">
|
||||
<code class="descname">forecast_interval</code><span class="sig-paren">(</span><em>data</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/mvfts.html#MVFTS.forecast_interval"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.mvfts.MVFTS.forecast_interval" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Interval forecast one step ahead</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
|
||||
<li><strong>data</strong> – time series data with the minimal length equal to the max_lag of the model</li>
|
||||
<li><strong>kwargs</strong> – model specific parameters</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a list with the prediction intervals</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.mvfts.MVFTS.format_data">
|
||||
<code class="descname">format_data</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/mvfts.html#MVFTS.format_data"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.mvfts.MVFTS.format_data" title="Permalink to this definition">¶</a></dt>
|
||||
@ -487,6 +540,22 @@ transformations and partitioners.</p>
|
||||
<code class="descname">append_rhs</code><span class="sig-paren">(</span><em>fset</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/wmvfts.html#WeightedFLRG.append_rhs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.wmvfts.WeightedFLRG.append_rhs" title="Permalink to this definition">¶</a></dt>
|
||||
<dd></dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_lower">
|
||||
<code class="descname">get_lower</code><span class="sig-paren">(</span><em>sets</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/wmvfts.html#WeightedFLRG.get_lower"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_lower" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the lower bound value for the RHS fuzzy sets</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>sets</strong> – fuzzy sets</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">lower bound value</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_midpoint">
|
||||
<code class="descname">get_midpoint</code><span class="sig-paren">(</span><em>sets</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/wmvfts.html#WeightedFLRG.get_midpoint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_midpoint" title="Permalink to this definition">¶</a></dt>
|
||||
@ -503,6 +572,22 @@ transformations and partitioners.</p>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_upper">
|
||||
<code class="descname">get_upper</code><span class="sig-paren">(</span><em>sets</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/wmvfts.html#WeightedFLRG.get_upper"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.wmvfts.WeightedFLRG.get_upper" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Returns the upper bound value for the RHS fuzzy sets</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>sets</strong> – fuzzy sets</td>
|
||||
</tr>
|
||||
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">upper bound value</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="pyFTS.models.multivariate.wmvfts.WeightedFLRG.weights">
|
||||
<code class="descname">weights</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pyFTS/models/multivariate/wmvfts.html#WeightedFLRG.weights"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyFTS.models.multivariate.wmvfts.WeightedFLRG.weights" title="Permalink to this definition">¶</a></dt>
|
||||
|
2
docs/build/html/searchindex.js
vendored
2
docs/build/html/searchindex.js
vendored
File diff suppressed because one or more lines are too long
@ -12,6 +12,8 @@ from pyFTS.probabilistic import ProbabilityDistribution
|
||||
from pyFTS.common import Transformations
|
||||
|
||||
|
||||
|
||||
|
||||
def plot_compared_intervals_ahead(original, models, colors, distributions, time_from, time_to, intervals = True,
|
||||
save=False, file=None, tam=[20, 5], resolution=None,
|
||||
cmap='Blues', linewidth=1.5):
|
||||
@ -124,6 +126,17 @@ def plot_probability_distributions(pmfs, lcolors, tam=[15, 7]):
|
||||
ax.legend(handles0, labels0)
|
||||
|
||||
def plot_distribution(ax, cmap, probabilitydist, fig, time_from, reference_data=None):
|
||||
'''
|
||||
Plot forecasted ProbabilityDistribution objects on a matplotlib axis
|
||||
|
||||
:param ax: matplotlib axis
|
||||
:param cmap: matplotlib colormap name
|
||||
:param probabilitydist: list of ProbabilityDistribution objects
|
||||
:param fig: matplotlib figure
|
||||
:param time_from: starting time (on x axis) to begin the plots
|
||||
:param reference_data:
|
||||
:return:
|
||||
'''
|
||||
from matplotlib.patches import Rectangle
|
||||
from matplotlib.collections import PatchCollection
|
||||
patches = []
|
||||
@ -149,6 +162,19 @@ def plot_distribution(ax, cmap, probabilitydist, fig, time_from, reference_data=
|
||||
|
||||
|
||||
def plot_interval(axis, intervals, order, label, color='red', typeonlegend=False, ls='-', linewidth=1):
|
||||
'''
|
||||
Plot forecasted intervals on matplotlib
|
||||
|
||||
:param axis: matplotlib axis
|
||||
:param intervals: list of forecasted intervals
|
||||
:param order: order of the model that create the forecasts
|
||||
:param label: figure label
|
||||
:param color: matplotlib color name
|
||||
:param typeonlegend:
|
||||
:param ls: matplotlib line style
|
||||
:param linewidth: matplotlib width
|
||||
:return:
|
||||
'''
|
||||
lower = [kk[0] for kk in intervals]
|
||||
upper = [kk[1] for kk in intervals]
|
||||
mi = min(lower) * 0.95
|
||||
@ -163,6 +189,16 @@ def plot_interval(axis, intervals, order, label, color='red', typeonlegend=False
|
||||
|
||||
|
||||
def plot_rules(model, size=[5, 5], axis=None, rules_by_axis=None, columns=1):
|
||||
'''
|
||||
Plot the FLRG rules of a FTS model on a matplotlib axis
|
||||
|
||||
:param model: FTS model
|
||||
:param size: figure size
|
||||
:param axis: matplotlib axis
|
||||
:param rules_by_axis: number of rules plotted by column
|
||||
:param columns: number of columns
|
||||
:return:
|
||||
'''
|
||||
if axis is None and rules_by_axis is None:
|
||||
rows = 1
|
||||
elif axis is None and rules_by_axis is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user