254 lines
29 KiB
HTML
254 lines
29 KiB
HTML
|
||
|
||
<!doctype html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||
<title>pyFTS.benchmarks.Tests — pyFTS 1.7 documentation</title>
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||
|
||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||
<script src="../../../_static/jquery.js"></script>
|
||
<script src="../../../_static/underscore.js"></script>
|
||
<script src="../../../_static/doctools.js"></script>
|
||
<script src="../../../_static/bizstyle.js"></script>
|
||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||
<link rel="search" title="Search" href="../../../search.html" />
|
||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||
<!--[if lt IE 9]>
|
||
<script src="_static/css3-mediaqueries.js"></script>
|
||
<![endif]-->
|
||
</head><body>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../../../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">pyFTS.benchmarks.Tests</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<h1>Source code for pyFTS.benchmarks.Tests</h1><div class="highlight"><pre>
|
||
<span></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">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||
|
||
<span class="kn">from</span> <span class="nn">pyFTS.benchmarks.Measures</span> <span class="k">import</span> <span class="n">acf</span>
|
||
|
||
|
||
<div class="viewcode-block" id="BoxPierceStatistic"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.Tests.BoxPierceStatistic">[docs]</a><span class="k">def</span> <span class="nf">BoxPierceStatistic</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">h</span><span class="p">):</span>
|
||
<span class="sd">"""</span>
|
||
<span class="sd"> Q Statistic for Box-Pierce test</span>
|
||
|
||
<span class="sd"> :param data:</span>
|
||
<span class="sd"> :param h:</span>
|
||
<span class="sd"> :return:</span>
|
||
<span class="sd"> """</span>
|
||
<span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||
<span class="n">s</span> <span class="o">=</span> <span class="mi">0</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">1</span><span class="p">,</span> <span class="n">h</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
|
||
<span class="n">r</span> <span class="o">=</span> <span class="n">acf</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||
<span class="n">s</span> <span class="o">+=</span> <span class="n">r</span> <span class="o">**</span> <span class="mi">2</span>
|
||
<span class="k">return</span> <span class="n">n</span> <span class="o">*</span> <span class="n">s</span></div>
|
||
|
||
|
||
<div class="viewcode-block" id="BoxLjungStatistic"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.Tests.BoxLjungStatistic">[docs]</a><span class="k">def</span> <span class="nf">BoxLjungStatistic</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">h</span><span class="p">):</span>
|
||
<span class="sd">"""</span>
|
||
<span class="sd"> Q Statistic for Ljung–Box test</span>
|
||
|
||
<span class="sd"> :param data:</span>
|
||
<span class="sd"> :param h:</span>
|
||
<span class="sd"> :return:</span>
|
||
<span class="sd"> """</span>
|
||
<span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||
<span class="n">s</span> <span class="o">=</span> <span class="mi">0</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">1</span><span class="p">,</span> <span class="n">h</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
|
||
<span class="n">r</span> <span class="o">=</span> <span class="n">acf</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||
<span class="n">s</span> <span class="o">+=</span> <span class="n">r</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">/</span> <span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="n">k</span><span class="p">)</span>
|
||
<span class="k">return</span> <span class="n">n</span> <span class="o">*</span> <span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">*</span> <span class="n">s</span></div>
|
||
|
||
|
||
<div class="viewcode-block" id="format_experiment_table"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.Tests.format_experiment_table">[docs]</a><span class="k">def</span> <span class="nf">format_experiment_table</span><span class="p">(</span><span class="n">df</span><span class="p">,</span> <span class="n">exclude</span><span class="o">=</span><span class="p">[],</span> <span class="n">replace</span><span class="o">=</span><span class="p">{},</span> <span class="n">csv</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">std</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
|
||
<span class="n">rows</span> <span class="o">=</span> <span class="p">[]</span>
|
||
<span class="n">columns</span> <span class="o">=</span> <span class="p">[]</span>
|
||
<span class="n">datasets</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">Dataset</span><span class="o">.</span><span class="n">unique</span><span class="p">()</span>
|
||
<span class="n">models</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">Model</span><span class="o">.</span><span class="n">unique</span><span class="p">()</span>
|
||
<span class="k">for</span> <span class="n">model</span> <span class="ow">in</span> <span class="n">models</span><span class="p">:</span>
|
||
<span class="n">test</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">any</span><span class="p">([</span><span class="n">model</span><span class="o">.</span><span class="n">rfind</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">exclude</span><span class="p">])</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">exclude</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="kc">False</span>
|
||
<span class="k">if</span> <span class="ow">not</span> <span class="n">test</span><span class="p">:</span>
|
||
<span class="n">columns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">model</span><span class="p">)</span>
|
||
|
||
<span class="k">for</span> <span class="n">dataset</span> <span class="ow">in</span> <span class="n">datasets</span><span class="p">:</span>
|
||
<span class="n">row</span> <span class="o">=</span> <span class="p">[</span><span class="n">dataset</span><span class="p">]</span>
|
||
<span class="k">if</span> <span class="n">std</span><span class="p">:</span>
|
||
<span class="n">row_std</span> <span class="o">=</span> <span class="p">[</span><span class="n">dataset</span><span class="p">]</span>
|
||
<span class="k">for</span> <span class="n">model</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span>
|
||
<span class="n">avg</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">df</span><span class="p">[(</span><span class="n">df</span><span class="o">.</span><span class="n">Dataset</span> <span class="o">==</span> <span class="n">dataset</span><span class="p">)</span> <span class="o">&</span> <span class="p">(</span><span class="n">df</span><span class="o">.</span><span class="n">Model</span> <span class="o">==</span> <span class="n">model</span><span class="p">)][</span><span class="s2">"AVG"</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
|
||
<span class="n">row</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">avg</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
|
||
<span class="k">if</span> <span class="n">std</span><span class="p">:</span>
|
||
<span class="n">_std</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">df</span><span class="p">[(</span><span class="n">df</span><span class="o">.</span><span class="n">Dataset</span> <span class="o">==</span> <span class="n">dataset</span><span class="p">)</span> <span class="o">&</span> <span class="p">(</span><span class="n">df</span><span class="o">.</span><span class="n">Model</span> <span class="o">==</span> <span class="n">model</span><span class="p">)][</span><span class="s2">"STD"</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
|
||
<span class="n">row_std</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"("</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">_std</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span> <span class="o">+</span> <span class="s2">")"</span><span class="p">)</span>
|
||
|
||
<span class="n">rows</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">row</span><span class="p">)</span>
|
||
<span class="k">if</span> <span class="n">std</span><span class="p">:</span>
|
||
<span class="n">rows</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">row_std</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="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)):</span>
|
||
<span class="k">if</span> <span class="n">columns</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="ow">in</span> <span class="n">replace</span><span class="p">:</span>
|
||
<span class="n">columns</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">replace</span><span class="p">[</span><span class="n">columns</span><span class="p">[</span><span class="n">k</span><span class="p">]]</span>
|
||
|
||
<span class="n">columns</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="s2">"dataset"</span><span class="p">)</span>
|
||
|
||
<span class="k">if</span> <span class="n">csv</span><span class="p">:</span>
|
||
<span class="n">header</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="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">columns</span><span class="p">)):</span>
|
||
<span class="k">if</span> <span class="n">k</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||
<span class="n">header</span> <span class="o">+=</span> <span class="s2">","</span>
|
||
<span class="n">header</span> <span class="o">+=</span> <span class="n">columns</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
|
||
|
||
<span class="n">body</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="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">rows</span><span class="p">)):</span>
|
||
<span class="n">row</span> <span class="o">=</span> <span class="s2">""</span>
|
||
<span class="k">for</span> <span class="n">w</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">rows</span><span class="p">[</span><span class="n">k</span><span class="p">])):</span>
|
||
<span class="k">if</span> <span class="n">w</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||
<span class="n">row</span> <span class="o">+=</span> <span class="s2">","</span>
|
||
<span class="n">row</span> <span class="o">+=</span> <span class="nb">str</span><span class="p">(</span><span class="n">rows</span><span class="p">[</span><span class="n">k</span><span class="p">][</span><span class="n">w</span><span class="p">])</span>
|
||
<span class="n">body</span> <span class="o">+=</span> <span class="s1">'</span><span class="se">\n</span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">row</span><span class="p">)</span>
|
||
|
||
<span class="k">return</span> <span class="n">header</span> <span class="o">+</span> <span class="n">body</span>
|
||
<span class="k">else</span><span class="p">:</span>
|
||
<span class="n">ret</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">rows</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">)</span>
|
||
<span class="k">return</span> <span class="n">ret</span></div>
|
||
|
||
|
||
<div class="viewcode-block" id="test_mean_equality"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.Tests.test_mean_equality">[docs]</a><span class="k">def</span> <span class="nf">test_mean_equality</span><span class="p">(</span><span class="n">tests</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=.</span><span class="mi">05</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">'friedman'</span><span class="p">):</span>
|
||
<span class="sd">"""</span>
|
||
<span class="sd"> Test for the equality of the means, with alpha confidence level.</span>
|
||
|
||
<span class="sd"> H_0: There's no significant difference between the means</span>
|
||
<span class="sd"> H_1: There is at least one significant difference between the means</span>
|
||
|
||
<span class="sd"> :param tests:</span>
|
||
<span class="sd"> :param alpha:</span>
|
||
<span class="sd"> :param method:</span>
|
||
<span class="sd"> :return:</span>
|
||
<span class="sd"> """</span>
|
||
<span class="kn">from</span> <span class="nn">stac.stac</span> <span class="k">import</span> <span class="n">nonparametric_tests</span> <span class="k">as</span> <span class="n">npt</span>
|
||
|
||
<span class="n">methods</span> <span class="o">=</span> <span class="n">tests</span><span class="o">.</span><span class="n">columns</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
|
||
|
||
<span class="n">values</span> <span class="o">=</span> <span class="p">[]</span>
|
||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">methods</span><span class="p">:</span>
|
||
<span class="n">values</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tests</span><span class="p">[</span><span class="n">k</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
|
||
|
||
<span class="k">if</span> <span class="n">method</span><span class="o">==</span><span class="s1">'quade'</span><span class="p">:</span>
|
||
<span class="n">f_value</span><span class="p">,</span> <span class="n">p_value</span><span class="p">,</span> <span class="n">rankings</span><span class="p">,</span> <span class="n">pivots</span> <span class="o">=</span> <span class="n">npt</span><span class="o">.</span><span class="n">quade_test</span><span class="p">(</span><span class="o">*</span><span class="n">values</span><span class="p">)</span>
|
||
<span class="k">elif</span> <span class="n">method</span><span class="o">==</span><span class="s1">'friedman'</span><span class="p">:</span>
|
||
<span class="n">f_value</span><span class="p">,</span> <span class="n">p_value</span><span class="p">,</span> <span class="n">rankings</span><span class="p">,</span> <span class="n">pivots</span> <span class="o">=</span> <span class="n">npt</span><span class="o">.</span><span class="n">friedman_aligned_ranks_test</span><span class="p">(</span><span class="o">*</span><span class="n">values</span><span class="p">)</span>
|
||
<span class="k">else</span><span class="p">:</span>
|
||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">'Unknown test method!'</span><span class="p">)</span>
|
||
|
||
<span class="nb">print</span><span class="p">(</span><span class="s2">"F-Value: </span><span class="si">{}</span><span class="s2"> </span><span class="se">\t</span><span class="s2">p-Value: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">f_value</span><span class="p">,</span> <span class="n">p_value</span><span class="p">))</span>
|
||
|
||
<span class="k">if</span> <span class="n">p_value</span> <span class="o"><</span> <span class="n">alpha</span><span class="p">:</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">H0 is rejected!</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
|
||
<span class="k">else</span><span class="p">:</span>
|
||
<span class="nb">print</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">H0 is accepted!</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
|
||
|
||
<span class="n">post_hoc</span> <span class="o">=</span> <span class="p">{}</span>
|
||
<span class="n">rows</span> <span class="o">=</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="nb">len</span><span class="p">(</span><span class="n">methods</span><span class="p">)):</span>
|
||
<span class="n">rows</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">methods</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="n">rankings</span><span class="p">[</span><span class="n">k</span><span class="p">]])</span>
|
||
<span class="n">post_hoc</span><span class="p">[</span><span class="n">methods</span><span class="p">[</span><span class="n">k</span><span class="p">]]</span> <span class="o">=</span> <span class="n">pivots</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
|
||
|
||
<span class="k">return</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="n">rows</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="s1">'METHOD'</span><span class="p">,</span> <span class="s1">'RANK'</span><span class="p">])</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">'RANK'</span><span class="p">]),</span> <span class="n">post_hoc</span><span class="p">]</span></div>
|
||
|
||
|
||
<div class="viewcode-block" id="post_hoc_tests"><a class="viewcode-back" href="../../../pyFTS.benchmarks.html#pyFTS.benchmarks.Tests.post_hoc_tests">[docs]</a><span class="k">def</span> <span class="nf">post_hoc_tests</span><span class="p">(</span><span class="n">post_hoc</span><span class="p">,</span> <span class="n">control_method</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=.</span><span class="mi">05</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">'finner'</span><span class="p">):</span>
|
||
<span class="sd">'''</span>
|
||
<span class="sd"> Finner paired post-hoc test with NSFTS as control method.</span>
|
||
|
||
<span class="sd"> $H_0$: There is no significant difference between the means</span>
|
||
|
||
<span class="sd"> $H_1$: There is a significant difference between the means</span>
|
||
|
||
<span class="sd"> :param post_hoc:</span>
|
||
<span class="sd"> :param control_method:</span>
|
||
<span class="sd"> :param alpha:</span>
|
||
<span class="sd"> :param method:</span>
|
||
<span class="sd"> :return:</span>
|
||
<span class="sd"> '''</span>
|
||
<span class="kn">from</span> <span class="nn">stac.stac</span> <span class="k">import</span> <span class="n">nonparametric_tests</span> <span class="k">as</span> <span class="n">npt</span>
|
||
|
||
<span class="k">if</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'bonferroni_dunn'</span><span class="p">:</span>
|
||
<span class="n">comparisons</span><span class="p">,</span> <span class="n">z_values</span><span class="p">,</span> <span class="n">p_values</span><span class="p">,</span> <span class="n">adj_p_values</span> <span class="o">=</span> <span class="n">npt</span><span class="o">.</span><span class="n">bonferroni_dunn_test</span><span class="p">(</span><span class="n">post_hoc</span><span class="p">,</span><span class="n">control_method</span><span class="p">)</span>
|
||
<span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'holm'</span><span class="p">:</span>
|
||
<span class="n">comparisons</span><span class="p">,</span> <span class="n">z_values</span><span class="p">,</span> <span class="n">p_values</span><span class="p">,</span> <span class="n">adj_p_values</span> <span class="o">=</span> <span class="n">npt</span><span class="o">.</span><span class="n">holm_test</span><span class="p">(</span><span class="n">post_hoc</span><span class="p">,</span><span class="n">control_method</span><span class="p">)</span>
|
||
<span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'finner'</span><span class="p">:</span>
|
||
<span class="n">comparisons</span><span class="p">,</span> <span class="n">z_values</span><span class="p">,</span> <span class="n">p_values</span><span class="p">,</span> <span class="n">adj_p_values</span> <span class="o">=</span> <span class="n">npt</span><span class="o">.</span><span class="n">finner_test</span><span class="p">(</span><span class="n">post_hoc</span><span class="p">,</span> <span class="n">control_method</span><span class="p">)</span>
|
||
<span class="k">else</span><span class="p">:</span>
|
||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">'Unknown test method!'</span><span class="p">)</span>
|
||
|
||
<span class="n">rows</span> <span class="o">=</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="nb">len</span><span class="p">(</span><span class="n">comparisons</span><span class="p">)):</span>
|
||
<span class="n">test</span> <span class="o">=</span> <span class="s1">'H0 Accepted'</span> <span class="k">if</span> <span class="n">adj_p_values</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">></span> <span class="n">alpha</span> <span class="k">else</span> <span class="s1">'H0 Rejected'</span>
|
||
<span class="n">rows</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">comparisons</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="n">z_values</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="n">p_values</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="n">adj_p_values</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="n">test</span><span class="p">])</span>
|
||
|
||
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">rows</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="s1">'COMPARISON'</span><span class="p">,</span> <span class="s1">'Z-VALUE'</span><span class="p">,</span> <span class="s1">'P-VALUE'</span><span class="p">,</span> <span class="s1">'ADJUSTED P-VALUE'</span><span class="p">,</span> <span class="s1">'Result'</span><span class="p">])</span></div>
|
||
|
||
</pre></div>
|
||
|
||
<div class="clearer"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../../../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>$('#searchbox').show(0);</script>
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../../../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">pyFTS.benchmarks.Tests</a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.5.0.
|
||
</div>
|
||
</body>
|
||
</html> |