<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">absolute_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.absolute_error"title="Link to this definition"></a></dt>
<dt>Computes the absolute error between the two prevalence vectors.</dt><dd><p>Absolute error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">acc_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">y_true</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">y_pred</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.acc_error"title="Link to this definition"></a></dt>
<dd><p>Computes the error in terms of 1-accuracy. The accuracy is computed as
<spanclass="math notranslate nohighlight">\(\frac{tp+tn}{tp+fp+fn+tn}\)</span>, with <cite>tp</cite>, <cite>fp</cite>, <cite>fn</cite>, and <cite>tn</cite> standing
for true positives, false positives, false negatives, and true negatives,
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">acce</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">y_true</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">y_pred</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#acce"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.acce"title="Link to this definition"></a></dt>
<dd><p>Computes the error in terms of 1-accuracy. The accuracy is computed as
<spanclass="math notranslate nohighlight">\(\frac{tp+tn}{tp+fp+fn+tn}\)</span>, with <cite>tp</cite>, <cite>fp</cite>, <cite>fn</cite>, and <cite>tn</cite> standing
for true positives, false positives, false negatives, and true negatives,
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">ae</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#ae"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.ae"title="Link to this definition"></a></dt>
<dt>Computes the absolute error between the two prevalence vectors.</dt><dd><p>Absolute error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">f1_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">y_true</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">y_pred</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.f1_error"title="Link to this definition"></a></dt>
<dd><p>F1 error: simply computes the error in terms of macro <spanclass="math notranslate nohighlight">\(F_1\)</span>, i.e.,
<spanclass="math notranslate nohighlight">\(1-F_1^M\)</span>, where <spanclass="math notranslate nohighlight">\(F_1\)</span> is the harmonic mean of precision and recall,
defined as <spanclass="math notranslate nohighlight">\(\frac{2tp}{2tp+fp+fn}\)</span>, with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing
for true positives, false positives, and false negatives, respectively.
<cite>Macro</cite> averaging means the <spanclass="math notranslate nohighlight">\(F_1\)</span> is computed for each category independently,
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">f1e</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">y_true</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">y_pred</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#f1e"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.f1e"title="Link to this definition"></a></dt>
<dd><p>F1 error: simply computes the error in terms of macro <spanclass="math notranslate nohighlight">\(F_1\)</span>, i.e.,
<spanclass="math notranslate nohighlight">\(1-F_1^M\)</span>, where <spanclass="math notranslate nohighlight">\(F_1\)</span> is the harmonic mean of precision and recall,
defined as <spanclass="math notranslate nohighlight">\(\frac{2tp}{2tp+fp+fn}\)</span>, with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing
for true positives, false positives, and false negatives, respectively.
<cite>Macro</cite> averaging means the <spanclass="math notranslate nohighlight">\(F_1\)</span> is computed for each category independently,
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">from_name</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">err_name</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#from_name"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.from_name"title="Link to this definition"></a></dt>
<dd><p>Gets an error function from its name. E.g., <cite>from_name(“mae”)</cite>
will return function <aclass="reference internal"href="#quapy.error.mae"title="quapy.error.mae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.mae()</span></code></a></p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">kld</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#kld"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.kld"title="Link to this definition"></a></dt>
<dt>Computes the Kullback-Leibler divergence between the two prevalence distributions.</dt><dd><p>Kullback-Leibler divergence between two prevalence distributions <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span>
The distributions are smoothed using the <cite>eps</cite> factor (see <aclass="reference internal"href="#quapy.error.smooth"title="quapy.error.smooth"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.smooth()</span></code></a>).</p>
<li><p><strong>eps</strong>– smoothing factor. KLD is not defined in cases in which the distributions contain
zeros; <cite>eps</cite> is typically set to be <spanclass="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <spanclass="math notranslate nohighlight">\(T\)</span> the sample size.
If <cite>eps=None</cite>, the sample size will be taken from the environment variable <cite>SAMPLE_SIZE</cite>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mae</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#mae"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.mae"title="Link to this definition"></a></dt>
<dd><p>Computes the mean absolute error (see <aclass="reference internal"href="#quapy.error.ae"title="quapy.error.ae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.ae()</span></code></a>) across the sample pairs.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mean_absolute_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.mean_absolute_error"title="Link to this definition"></a></dt>
<dd><p>Computes the mean absolute error (see <aclass="reference internal"href="#quapy.error.ae"title="quapy.error.ae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.ae()</span></code></a>) across the sample pairs.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mean_normalized_absolute_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.mean_normalized_absolute_error"title="Link to this definition"></a></dt>
<dd><p>Computes the mean normalized absolute error (see <aclass="reference internal"href="#quapy.error.nae"title="quapy.error.nae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.nae()</span></code></a>) across the sample pairs.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mean_normalized_relative_absolute_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.mean_normalized_relative_absolute_error"title="Link to this definition"></a></dt>
<dd><p>Computes the mean normalized relative absolute error (see <aclass="reference internal"href="#quapy.error.nrae"title="quapy.error.nrae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.nrae()</span></code></a>) across
the sample pairs. The distributions are smoothed using the <cite>eps</cite> factor (see
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mean_relative_absolute_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.mean_relative_absolute_error"title="Link to this definition"></a></dt>
<dd><p>Computes the mean relative absolute error (see <aclass="reference internal"href="#quapy.error.rae"title="quapy.error.rae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.rae()</span></code></a>) across
the sample pairs. The distributions are smoothed using the <cite>eps</cite> factor (see
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mkld</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#mkld"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.mkld"title="Link to this definition"></a></dt>
<dd><p>Computes the mean Kullback-Leibler divergence (see <aclass="reference internal"href="#quapy.error.kld"title="quapy.error.kld"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.kld()</span></code></a>) across the
sample pairs. The distributions are smoothed using the <cite>eps</cite> factor
(see <aclass="reference internal"href="#quapy.error.smooth"title="quapy.error.smooth"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.smooth()</span></code></a>).</p>
<li><p><strong>prevs</strong>– array-like of shape <cite>(n_samples, n_classes,)</cite> with the true
prevalence values</p></li>
<li><p><strong>prevs_hat</strong>– array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted
prevalence values</p></li>
<li><p><strong>eps</strong>– smoothing factor. KLD is not defined in cases in which the distributions contain
zeros; <cite>eps</cite> is typically set to be <spanclass="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <spanclass="math notranslate nohighlight">\(T\)</span> the sample size.
If <cite>eps=None</cite>, the sample size will be taken from the environment variable <cite>SAMPLE_SIZE</cite>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mnae</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#mnae"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.mnae"title="Link to this definition"></a></dt>
<dd><p>Computes the mean normalized absolute error (see <aclass="reference internal"href="#quapy.error.nae"title="quapy.error.nae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.nae()</span></code></a>) across the sample pairs.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mnkld</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#mnkld"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.mnkld"title="Link to this definition"></a></dt>
<dd><p>Computes the mean Normalized Kullback-Leibler divergence (see <aclass="reference internal"href="#quapy.error.nkld"title="quapy.error.nkld"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.nkld()</span></code></a>)
across the sample pairs. The distributions are smoothed using the <cite>eps</cite> factor
(see <aclass="reference internal"href="#quapy.error.smooth"title="quapy.error.smooth"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.smooth()</span></code></a>).</p>
<li><p><strong>prevs_hat</strong>– array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted
prevalence values</p></li>
<li><p><strong>eps</strong>– smoothing factor. NKLD is not defined in cases in which the distributions contain
zeros; <cite>eps</cite> is typically set to be <spanclass="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <spanclass="math notranslate nohighlight">\(T\)</span> the sample size.
If <cite>eps=None</cite>, the sample size will be taken from the environment variable <cite>SAMPLE_SIZE</cite>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mnrae</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#mnrae"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.mnrae"title="Link to this definition"></a></dt>
<dd><p>Computes the mean normalized relative absolute error (see <aclass="reference internal"href="#quapy.error.nrae"title="quapy.error.nrae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.nrae()</span></code></a>) across
the sample pairs. The distributions are smoothed using the <cite>eps</cite> factor (see
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mrae</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#mrae"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.mrae"title="Link to this definition"></a></dt>
<dd><p>Computes the mean relative absolute error (see <aclass="reference internal"href="#quapy.error.rae"title="quapy.error.rae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.rae()</span></code></a>) across
the sample pairs. The distributions are smoothed using the <cite>eps</cite> factor (see
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">mse</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#mse"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.mse"title="Link to this definition"></a></dt>
<dd><p>Computes the mean squared error (see <aclass="reference internal"href="#quapy.error.se"title="quapy.error.se"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.se()</span></code></a>) across the sample pairs.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">nae</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#nae"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.nae"title="Link to this definition"></a></dt>
<dd><dlclass="simple">
<dt>Computes the normalized absolute error between the two prevalence vectors.</dt><dd><p>Normalized absolute error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
where <spanclass="math notranslate nohighlight">\(z_{AE}=\frac{2(1-\min_{y\in \mathcal{Y}} p(y))}{|\mathcal{Y}|}\)</span>, and <spanclass="math notranslate nohighlight">\(\mathcal{Y}\)</span>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">nkld</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#nkld"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.nkld"title="Link to this definition"></a></dt>
<dt>Computes the Normalized Kullback-Leibler divergence between the two prevalence distributions.</dt><dd><p>Normalized Kullback-Leibler divergence between two prevalence distributions <spanclass="math notranslate nohighlight">\(p\)</span> and
<spanclass="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
<spanclass="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
The distributions are smoothed using the <cite>eps</cite> factor (see <aclass="reference internal"href="#quapy.error.smooth"title="quapy.error.smooth"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.smooth()</span></code></a>).</p>
<li><p><strong>eps</strong>– smoothing factor. NKLD is not defined in cases in which the distributions
contain zeros; <cite>eps</cite> is typically set to be <spanclass="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <spanclass="math notranslate nohighlight">\(T\)</span> the sample
size. If <cite>eps=None</cite>, the sample size will be taken from the environment variable
<cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">normalized_absolute_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.normalized_absolute_error"title="Link to this definition"></a></dt>
<dt>Computes the normalized absolute error between the two prevalence vectors.</dt><dd><p>Normalized absolute error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
where <spanclass="math notranslate nohighlight">\(z_{AE}=\frac{2(1-\min_{y\in \mathcal{Y}} p(y))}{|\mathcal{Y}|}\)</span>, and <spanclass="math notranslate nohighlight">\(\mathcal{Y}\)</span>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">normalized_relative_absolute_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.normalized_relative_absolute_error"title="Link to this definition"></a></dt>
<dd><dlclass="simple">
<dt>Computes the normalized absolute relative error between the two prevalence vectors.</dt><dd><p>Relative absolute error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span>
and <spanclass="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
The distributions are smoothed using the <cite>eps</cite> factor (see <aclass="reference internal"href="#quapy.error.smooth"title="quapy.error.smooth"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.smooth()</span></code></a>).</p>
<li><p><strong>prevs</strong>– array-like of shape <cite>(n_classes,)</cite> with the true prevalence values</p></li>
<li><p><strong>prevs_hat</strong>– array-like of shape <cite>(n_classes,)</cite> with the predicted prevalence values</p></li>
<li><p><strong>eps</strong>– smoothing factor. <cite>nrae</cite> is not defined in cases in which the true distribution
contains zeros; <cite>eps</cite> is typically set to be <spanclass="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <spanclass="math notranslate nohighlight">\(T\)</span> the
sample size. If <cite>eps=None</cite>, the sample size will be taken from the environment variable
<cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">nrae</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#nrae"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.nrae"title="Link to this definition"></a></dt>
<dd><dlclass="simple">
<dt>Computes the normalized absolute relative error between the two prevalence vectors.</dt><dd><p>Relative absolute error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span>
and <spanclass="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
The distributions are smoothed using the <cite>eps</cite> factor (see <aclass="reference internal"href="#quapy.error.smooth"title="quapy.error.smooth"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.smooth()</span></code></a>).</p>
<li><p><strong>prevs</strong>– array-like of shape <cite>(n_classes,)</cite> with the true prevalence values</p></li>
<li><p><strong>prevs_hat</strong>– array-like of shape <cite>(n_classes,)</cite> with the predicted prevalence values</p></li>
<li><p><strong>eps</strong>– smoothing factor. <cite>nrae</cite> is not defined in cases in which the true distribution
contains zeros; <cite>eps</cite> is typically set to be <spanclass="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <spanclass="math notranslate nohighlight">\(T\)</span> the
sample size. If <cite>eps=None</cite>, the sample size will be taken from the environment variable
<cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">rae</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#rae"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.rae"title="Link to this definition"></a></dt>
<dd><dlclass="simple">
<dt>Computes the absolute relative error between the two prevalence vectors.</dt><dd><p>Relative absolute error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span>
where <spanclass="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
The distributions are smoothed using the <cite>eps</cite> factor (see <aclass="reference internal"href="#quapy.error.smooth"title="quapy.error.smooth"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.smooth()</span></code></a>).</p>
<li><p><strong>prevs</strong>– array-like of shape <cite>(n_classes,)</cite> with the true prevalence values</p></li>
<li><p><strong>prevs_hat</strong>– array-like of shape <cite>(n_classes,)</cite> with the predicted prevalence values</p></li>
<li><p><strong>eps</strong>– smoothing factor. <cite>rae</cite> is not defined in cases in which the true distribution
contains zeros; <cite>eps</cite> is typically set to be <spanclass="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <spanclass="math notranslate nohighlight">\(T\)</span> the
sample size. If <cite>eps=None</cite>, the sample size will be taken from the environment variable
<cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">relative_absolute_error</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.error.relative_absolute_error"title="Link to this definition"></a></dt>
<dt>Computes the absolute relative error between the two prevalence vectors.</dt><dd><p>Relative absolute error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span>
where <spanclass="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
The distributions are smoothed using the <cite>eps</cite> factor (see <aclass="reference internal"href="#quapy.error.smooth"title="quapy.error.smooth"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.smooth()</span></code></a>).</p>
<li><p><strong>eps</strong>– smoothing factor. <cite>rae</cite> is not defined in cases in which the true distribution
contains zeros; <cite>eps</cite> is typically set to be <spanclass="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <spanclass="math notranslate nohighlight">\(T\)</span> the
sample size. If <cite>eps=None</cite>, the sample size will be taken from the environment variable
<cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">se</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prevs_hat</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#se"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.se"title="Link to this definition"></a></dt>
<dt>Computes the squared error between the two prevalence vectors.</dt><dd><p>Squared error between two prevalence vectors <spanclass="math notranslate nohighlight">\(p\)</span> and <spanclass="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.error.</span></span><spanclass="sig-name descname"><spanclass="pre">smooth</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">eps</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/error.html#smooth"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.error.smooth"title="Link to this definition"></a></dt>
<spanid="quapy-evaluation-module"></span><h2>quapy.evaluation module<aclass="headerlink"href="#module-quapy.evaluation"title="Link to this heading"></a></h2>
<li><p><strong>model</strong>– a quantifier, instance of <aclass="reference internal"href="quapy.method.html#quapy.method.base.BaseQuantifier"title="quapy.method.base.BaseQuantifier"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.method.base.BaseQuantifier</span></code></a></p></li>
<li><p><strong>protocol</strong>–<aclass="reference internal"href="#quapy.protocol.AbstractProtocol"title="quapy.protocol.AbstractProtocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.protocol.AbstractProtocol</span></code></a>; if this object is also instance of
<aclass="reference internal"href="#quapy.protocol.OnLabelledCollectionProtocol"title="quapy.protocol.OnLabelledCollectionProtocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.protocol.OnLabelledCollectionProtocol</span></code></a>, then the aggregation speed-up can be run. This is the
protocol in charge of generating the samples in which the model is evaluated.</p></li>
<li><p><strong>error_metric</strong>– a string representing the name(s) of an error function in <cite>qp.error</cite>
(e.g., ‘mae’), or a callable function implementing the error function itself.</p></li>
<li><p><strong>aggr_speedup</strong>– whether or not to apply the speed-up. Set to “force” for applying it even if the number of
instances in the original collection on which the protocol acts is larger than the number of instances
in the samples to be generated. Set to True or “auto” (default) for letting QuaPy decide whether it is
convenient or not. Set to False to deactivate.</p></li>
<li><p><strong>verbose</strong>– boolean, show or not information in stdout</p></li>
<li><p><strong>model</strong>– a quantifier, instance of <aclass="reference internal"href="quapy.method.html#quapy.method.base.BaseQuantifier"title="quapy.method.base.BaseQuantifier"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.method.base.BaseQuantifier</span></code></a></p></li>
<li><p><strong>protocol</strong>–<aclass="reference internal"href="#quapy.protocol.AbstractProtocol"title="quapy.protocol.AbstractProtocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.protocol.AbstractProtocol</span></code></a>; if this object is also instance of
<aclass="reference internal"href="#quapy.protocol.OnLabelledCollectionProtocol"title="quapy.protocol.OnLabelledCollectionProtocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.protocol.OnLabelledCollectionProtocol</span></code></a>, then the aggregation speed-up can be run. This is the protocol
in charge of generating the samples in which the model is evaluated.</p></li>
<li><p><strong>error_metrics</strong>– a string, or list of strings, representing the name(s) of an error function in <cite>qp.error</cite>
(e.g., ‘mae’, the default value), or a callable function, or a list of callable functions, implementing
the error function itself.</p></li>
<li><p><strong>aggr_speedup</strong>– whether or not to apply the speed-up. Set to “force” for applying it even if the number of
instances in the original collection on which the protocol acts is larger than the number of instances
in the samples to be generated. Set to True or “auto” (default) for letting QuaPy decide whether it is
convenient or not. Set to False to deactivate.</p></li>
<li><p><strong>verbose</strong>– boolean, show or not information in stdout</p></li>
<li><p><strong>model</strong>– a quantifier, instance of <aclass="reference internal"href="quapy.method.html#quapy.method.base.BaseQuantifier"title="quapy.method.base.BaseQuantifier"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.method.base.BaseQuantifier</span></code></a></p></li>
<li><p><strong>protocol</strong>–<aclass="reference internal"href="#quapy.protocol.AbstractProtocol"title="quapy.protocol.AbstractProtocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.protocol.AbstractProtocol</span></code></a>; if this object is also instance of
<aclass="reference internal"href="#quapy.protocol.OnLabelledCollectionProtocol"title="quapy.protocol.OnLabelledCollectionProtocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.protocol.OnLabelledCollectionProtocol</span></code></a>, then the aggregation speed-up can be run. This is the protocol
in charge of generating the samples for which the model has to issue class prevalence predictions.</p></li>
<li><p><strong>aggr_speedup</strong>– whether or not to apply the speed-up. Set to “force” for applying it even if the number of
instances in the original collection on which the protocol acts is larger than the number of instances
in the samples to be generated. Set to True or “auto” (default) for letting QuaPy decide whether it is
convenient or not. Set to False to deactivate.</p></li>
<li><p><strong>verbose</strong>– boolean, show or not information in stdout</p></li>
<spanid="quapy-functional-module"></span><h2>quapy.functional module<aclass="headerlink"href="#module-quapy.functional"title="Link to this heading"></a></h2>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">HellingerDistance</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">P</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">Q</span></span></em><spanclass="sig-paren">)</span><spanclass="sig-return"><spanclass="sig-return-icon">→</span><spanclass="sig-return-typehint"><spanclass="pre">float</span></span></span><aclass="reference internal"href="_modules/quapy/functional.html#HellingerDistance"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.HellingerDistance"title="Link to this definition"></a></dt>
<dd><p>Computes the Hellingher Distance (HD) between (discretized) distributions <cite>P</cite> and <cite>Q</cite>.
The HD for two discrete distributions of <cite>k</cite> bins is defined as:</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">TopsoeDistance</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">P</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">Q</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">epsilon</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">1e-20</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#TopsoeDistance"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.TopsoeDistance"title="Link to this definition"></a></dt>
<dd><p>Topsoe distance between two (discretized) distributions <cite>P</cite> and <cite>Q</cite>.
The Topsoe distance for two discrete distributions of <cite>k</cite> bins is defined as:</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">adjusted_quantification</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevalence_estim</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">tpr</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">fpr</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">clip</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#adjusted_quantification"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.adjusted_quantification"title="Link to this definition"></a></dt>
<dd><p>Implements the adjustment of ACC and PACC for the binary case. The adjustment for a prevalence estimate of the
positive class <cite>p</cite> comes down to computing:</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">argmin_prevalence</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">loss</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_classes</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">method</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">'optim_minimize'</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#argmin_prevalence"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.argmin_prevalence"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">as_binary_prevalence</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">positive_prevalence</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">float</span><spanclass="w"></span><spanclass="p"><spanclass="pre">|</span></span><spanclass="w"></span><spanclass="pre">ndarray</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">clip_if_necessary</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">False</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#as_binary_prevalence"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.as_binary_prevalence"title="Link to this definition"></a></dt>
<dd><p>Helper that, given a float representing the prevalence for the positive class, returns a np.ndarray of two
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">check_prevalence_vector</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">p</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">raise_exception</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">False</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">toleranze</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">1e-08</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#check_prevalence_vector"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.check_prevalence_vector"title="Link to this definition"></a></dt>
<dd><p>Checks that p is a valid prevalence vector, i.e., that it contains values in [0,1] and that the values sum up to 1.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">get_divergence</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">divergence</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">str</span><spanclass="w"></span><spanclass="p"><spanclass="pre">|</span></span><spanclass="w"></span><spanclass="pre">Callable</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#get_divergence"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.get_divergence"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">get_nprevpoints_approximation</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">combinations_budget</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">int</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_classes</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">int</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_repeats</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">int</span></span><spanclass="w"></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="default_value"><spanclass="pre">1</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#get_nprevpoints_approximation"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.get_nprevpoints_approximation"title="Link to this definition"></a></dt>
<dd><p>Searches for the largest number of (equidistant) prevalence points to define for each of the <cite>n_classes</cite> classes so
that the number of valid prevalence values generated as combinations of prevalence points (points in a
<cite>n_classes</cite>-dimensional simplex) do not exceed combinations_budget.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">linear_search</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">loss</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_classes</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#linear_search"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.linear_search"title="Link to this definition"></a></dt>
<dd><p>Performs a linear search for the best prevalence value in binary problems. The search is carried out by exploring
the range [0,1] stepping by 0.01. This search is inefficient, and is added only for completeness (some of the
early methods in quantification literature used it, e.g., HDy). A most powerful alternative is <cite>optim_minimize</cite>.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">normalize_prevalence</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevalences</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#normalize_prevalence"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.normalize_prevalence"title="Link to this definition"></a></dt>
<dd><p>Normalize a vector or matrix of prevalence values. The normalization consists of applying a L1 normalization in
cases in which the prevalence values are not all-zeros, and to convert the prevalence values into <cite>1/n_classes</cite> in
<ddclass="field-odd"><p><strong>prevalences</strong>– array-like of shape <cite>(n_classes,)</cite> or of shape <cite>(n_samples, n_classes,)</cite> with prevalence values</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">num_prevalence_combinations</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">n_prevpoints</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">int</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_classes</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">int</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_repeats</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">int</span></span><spanclass="w"></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="default_value"><spanclass="pre">1</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#num_prevalence_combinations"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.num_prevalence_combinations"title="Link to this definition"></a></dt>
<dd><p>Computes the number of valid prevalence combinations in the n_classes-dimensional simplex if <cite>n_prevpoints</cite> equally
distant prevalence values are generated and <cite>n_repeats</cite> repetitions are requested.
The computation comes down to calculating:</p>
<divclass="math notranslate nohighlight">
\[\binom{N+C-1}{C-1} \times r\]</div>
<p>where <cite>N</cite> is <cite>n_prevpoints-1</cite>, i.e., the number of probability mass blocks to allocate, <cite>C</cite> is the number of
classes, and <cite>r</cite> is <cite>n_repeats</cite>. This solution comes from the
<aclass="reference external"href="https://brilliant.org/wiki/integer-equations-star-and-bars/">Stars and Bars</a> problem.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">optim_minimize</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">loss</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_classes</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#optim_minimize"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.optim_minimize"title="Link to this definition"></a></dt>
<dd><p>Searches for the optimal prevalence values, i.e., an <cite>n_classes</cite>-dimensional vector of the (<cite>n_classes</cite>-1)-simplex
that yields the smallest lost. This optimization is carried out by means of a constrained search using scipy’s
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">prevalence_from_labels</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">labels</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">classes</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#prevalence_from_labels"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.prevalence_from_labels"title="Link to this definition"></a></dt>
<dd><p>Computed the prevalence values from a vector of labels.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">prevalence_from_probabilities</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">posteriors</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">binarize</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">bool</span></span><spanclass="w"></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="default_value"><spanclass="pre">False</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#prevalence_from_probabilities"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.prevalence_from_probabilities"title="Link to this definition"></a></dt>
<dd><p>Returns a vector of prevalence values from a matrix of posterior probabilities.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">prevalence_linspace</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">n_prevalences</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">21</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">repeats</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">1</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">smooth_limits_epsilon</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">0.01</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#prevalence_linspace"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.prevalence_linspace"title="Link to this definition"></a></dt>
<dd><p>Produces an array of uniformly separated values of prevalence.
By default, produces an array of 21 prevalence values, with
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">strprev</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">prevalences</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">prec</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">3</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#strprev"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.strprev"title="Link to this definition"></a></dt>
<dd><p>Returns a string representation for a prevalence vector. E.g.,</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">uniform_prevalence_sampling</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">n_classes</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">size</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">1</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/functional.html#uniform_prevalence_sampling"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.functional.uniform_prevalence_sampling"title="Link to this definition"></a></dt>
<dd><p>Implements the <aclass="reference external"href="http://www.cs.cmu.edu/~nasmith/papers/smith+tromble.tr04.pdf">Kraemer algorithm</a>
for sampling uniformly at random from the unit simplex. This implementation is adapted from this
<ddclass="field-even"><p><cite>np.ndarray</cite> of shape <cite>(size, n_classes,)</cite> if <cite>size>1</cite>, or of shape <cite>(n_classes,)</cite> otherwise</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.functional.</span></span><spanclass="sig-name descname"><spanclass="pre">uniform_simplex_sampling</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">n_classes</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">size</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">1</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.functional.uniform_simplex_sampling"title="Link to this definition"></a></dt>
<dd><p>Implements the <aclass="reference external"href="http://www.cs.cmu.edu/~nasmith/papers/smith+tromble.tr04.pdf">Kraemer algorithm</a>
for sampling uniformly at random from the unit simplex. This implementation is adapted from this
<ddclass="field-even"><p><cite>np.ndarray</cite> of shape <cite>(size, n_classes,)</cite> if <cite>size>1</cite>, or of shape <cite>(n_classes,)</cite> otherwise</p>
<spanid="quapy-model-selection-module"></span><h2>quapy.model_selection module<aclass="headerlink"href="#module-quapy.model_selection"title="Link to this heading"></a></h2>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.model_selection.</span></span><spanclass="sig-name descname"><spanclass="pre">ConfigStatus</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">params</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">status</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">msg</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">''</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#ConfigStatus"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.ConfigStatus"title="Link to this definition"></a></dt>
<spanclass="sig-name descname"><spanclass="pre">failed</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#ConfigStatus.failed"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.ConfigStatus.failed"title="Link to this definition"></a></dt>
<spanclass="sig-name descname"><spanclass="pre">success</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#ConfigStatus.success"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.ConfigStatus.success"title="Link to this definition"></a></dt>
<li><p><strong>model</strong> (<aclass="reference internal"href="quapy.method.html#quapy.method.base.BaseQuantifier"title="quapy.method.base.BaseQuantifier"><em>BaseQuantifier</em></a>) – the quantifier to optimize</p></li>
<li><p><strong>param_grid</strong>– a dictionary with keys the parameter names and values the list of values to explore</p></li>
<li><p><strong>protocol</strong>– a sample generation protocol, an instance of <aclass="reference internal"href="#quapy.protocol.AbstractProtocol"title="quapy.protocol.AbstractProtocol"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.protocol.AbstractProtocol</span></code></a></p></li>
<li><p><strong>error</strong>– an error function (callable) or a string indicating the name of an error function (valid ones
are those in <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.error.QUANTIFICATION_ERROR</span></code></p></li>
<li><p><strong>refit</strong>– whether to refit the model on the whole labelled collection (training+validation) with
the best chosen hyperparameter combination. Ignored if protocol=’gen’</p></li>
<li><p><strong>timeout</strong>– establishes a timer (in seconds) for each of the hyperparameters configurations being tested.
Whenever a run takes longer than this timer, that configuration will be ignored. If all configurations end up
being ignored, a TimeoutError exception is raised. If -1 (default) then no time bound is set.</p></li>
<li><p><strong>raise_errors</strong>– boolean, if True then raises an exception when a param combination yields any error, if
otherwise is False (default), then the combination is marked with an error status, but the process goes on.
However, if no configuration yields a valid model, then a ValueError exception will be raised.</p></li>
<li><p><strong>verbose</strong>– set to True to get information through the stdout</p></li>
<spanclass="sig-name descname"><spanclass="pre">best_model</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#GridSearchQ.best_model"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.GridSearchQ.best_model"title="Link to this definition"></a></dt>
<dd><p>Returns the best model found after calling the <aclass="reference internal"href="#quapy.model_selection.GridSearchQ.fit"title="quapy.model_selection.GridSearchQ.fit"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">fit()</span></code></a> method, i.e., the one trained on the combination
of hyper-parameters that minimized the error function.</p>
<spanclass="sig-name descname"><spanclass="pre">fit</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">training</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><aclass="reference internal"href="quapy.data.html#quapy.data.base.LabelledCollection"title="quapy.data.base.LabelledCollection"><spanclass="pre">LabelledCollection</span></a></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#GridSearchQ.fit"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.GridSearchQ.fit"title="Link to this definition"></a></dt>
<dd><dlclass="simple">
<dt>Learning routine. Fits methods with all combinations of hyperparameters and selects the one minimizing</dt><dd><p>the error metric.</p>
<spanclass="sig-name descname"><spanclass="pre">get_params</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">deep</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#GridSearchQ.get_params"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.GridSearchQ.get_params"title="Link to this definition"></a></dt>
<dd><p>Returns the dictionary of hyper-parameters to explore (<cite>param_grid</cite>)</p>
<spanclass="sig-name descname"><spanclass="pre">quantify</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">instances</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#GridSearchQ.quantify"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.GridSearchQ.quantify"title="Link to this definition"></a></dt>
<dd><p>Estimate class prevalence values using the best model found after calling the <aclass="reference internal"href="#quapy.model_selection.GridSearchQ.fit"title="quapy.model_selection.GridSearchQ.fit"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">fit()</span></code></a> method.</p>
<spanclass="sig-name descname"><spanclass="pre">set_params</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">parameters</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#GridSearchQ.set_params"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.GridSearchQ.set_params"title="Link to this definition"></a></dt>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.model_selection.</span></span><spanclass="sig-name descname"><spanclass="pre">Status</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">value</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#Status"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.Status"title="Link to this definition"></a></dt>
<spanclass="sig-name descname"><spanclass="pre">ERROR</span></span><emclass="property"><spanclass="w"></span><spanclass="p"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="pre">4</span></em><aclass="headerlink"href="#quapy.model_selection.Status.ERROR"title="Link to this definition"></a></dt>
<spanclass="sig-name descname"><spanclass="pre">INVALID</span></span><emclass="property"><spanclass="w"></span><spanclass="p"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="pre">3</span></em><aclass="headerlink"href="#quapy.model_selection.Status.INVALID"title="Link to this definition"></a></dt>
<spanclass="sig-name descname"><spanclass="pre">SUCCESS</span></span><emclass="property"><spanclass="w"></span><spanclass="p"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="pre">1</span></em><aclass="headerlink"href="#quapy.model_selection.Status.SUCCESS"title="Link to this definition"></a></dt>
<spanclass="sig-name descname"><spanclass="pre">TIMEOUT</span></span><emclass="property"><spanclass="w"></span><spanclass="p"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="pre">2</span></em><aclass="headerlink"href="#quapy.model_selection.Status.TIMEOUT"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.model_selection.</span></span><spanclass="sig-name descname"><spanclass="pre">cross_val_predict</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">quantifier</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><aclass="reference internal"href="quapy.method.html#quapy.method.base.BaseQuantifier"title="quapy.method.base.BaseQuantifier"><spanclass="pre">BaseQuantifier</span></a></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">data</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><aclass="reference internal"href="quapy.data.html#quapy.data.base.LabelledCollection"title="quapy.data.base.LabelledCollection"><spanclass="pre">LabelledCollection</span></a></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">nfolds</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">3</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">random_state</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">0</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#cross_val_predict"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.cross_val_predict"title="Link to this definition"></a></dt>
<dd><p>Akin to <aclass="reference external"href="https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.cross_val_predict.html">scikit-learn’s cross_val_predict</a>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.model_selection.</span></span><spanclass="sig-name descname"><spanclass="pre">expand_grid</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">param_grid</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">dict</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#expand_grid"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.expand_grid"title="Link to this definition"></a></dt>
<dd><p>Expands a param_grid dictionary as a list of configurations.
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.model_selection.</span></span><spanclass="sig-name descname"><spanclass="pre">group_params</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">param_grid</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">dict</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/model_selection.html#group_params"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.model_selection.group_params"title="Link to this definition"></a></dt>
<dd><p>Partitions a param_grid dictionary as two lists of configurations, one for the classifier-specific
hyper-parameters, and another for que quantifier-specific hyper-parameters</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.plot.</span></span><spanclass="sig-name descname"><spanclass="pre">binary_diagonal</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">method_names</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">true_prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">estim_prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">pos_class</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">1</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">title</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">show_std</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">legend</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">train_prev</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">savepath</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">method_order</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/plot.html#binary_diagonal"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.plot.binary_diagonal"title="Link to this definition"></a></dt>
<dd><p>The diagonal plot displays the predicted prevalence values (along the y-axis) as a function of the true prevalence
values (along the x-axis). The optimal quantifier is described by the diagonal (0,0)-(1,1) of the plot (hence the
name). It is convenient for binary quantification problems, though it can be used for multiclass problems by
indicating which class is to be taken as the positive class. (For multiclass quantification problems, other plots
like the <aclass="reference internal"href="#quapy.plot.error_by_drift"title="quapy.plot.error_by_drift"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">error_by_drift()</span></code></a> might be preferable though).</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.plot.</span></span><spanclass="sig-name descname"><spanclass="pre">error_by_drift</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">method_names</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">true_prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">estim_prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">tr_prevs</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_bins</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">20</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">error_name</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">'ae'</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">show_std</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">False</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">show_density</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">show_legend</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">logscale</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">False</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">title</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">'Quantification</span><spanclass="pre">error</span><spanclass="pre">as</span><spanclass="pre">a</span><spanclass="pre">function</span><spanclass="pre">of</span><spanclass="pre">distribution</span><spanclass="pre">shift'</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">vlines</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">method_order</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">savepath</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/plot.html#error_by_drift"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.plot.error_by_drift"title="Link to this definition"></a></dt>
<dd><p>Plots the error (along the x-axis, as measured in terms of <cite>error_name</cite>) as a function of the train-test shift
(along the y-axis, as measured in terms of <aclass="reference internal"href="#quapy.error.ae"title="quapy.error.ae"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">quapy.error.ae()</span></code></a>). This plot is useful especially for multiclass
problems, in which “diagonal plots” may be cumbersone, and in order to gain understanding about how methods
fare in different regions of the prior probability shift spectrum (e.g., in the low-shift regime vs. in the
<li><p><strong>method_names</strong>– array-like with the method names for each experiment</p></li>
<li><p><strong>true_prevs</strong>– array-like with the true prevalence values (each being a ndarray with n_classes components) for
each experiment</p></li>
<li><p><strong>estim_prevs</strong>– array-like with the estimated prevalence values (each being a ndarray with n_classes components)
for each experiment</p></li>
<li><p><strong>tr_prevs</strong>– training prevalence of each experiment</p></li>
<li><p><strong>n_bins</strong>– number of bins in which the y-axis is to be divided (default is 20)</p></li>
<li><p><strong>error_name</strong>– a string representing the name of an error function (as defined in <cite>quapy.error</cite>, default is “ae”)</p></li>
<li><p><strong>show_std</strong>– whether or not to show standard deviations as color bands (default is False)</p></li>
<li><p><strong>show_density</strong>– whether or not to display the distribution of experiments for each bin (default is True)</p></li>
<li><p><strong>show_density</strong>– whether or not to display the legend of the chart (default is True)</p></li>
<li><p><strong>logscale</strong>– whether or not to log-scale the y-error measure (default is False)</p></li>
<li><p><strong>title</strong>– title of the plot (default is “Quantification error as a function of distribution shift”)</p></li>
<li><p><strong>vlines</strong>– array-like list of values (default is None). If indicated, highlights some regions of the space
using vertical dotted lines.</p></li>
<li><p><strong>method_order</strong>– if indicated (default is None), imposes the order in which the methods are processed (i.e.,
listed in the legend and associated with matplotlib colors).</p></li>
<li><p><strong>savepath</strong>– path where to save the plot. If not indicated (as default), the plot is shown.</p></li>
<spanid="quapy-protocol-module"></span><h2>quapy.protocol module<aclass="headerlink"href="#module-quapy.protocol"title="Link to this heading"></a></h2>
<spanclass="sig-name descname"><spanclass="pre">prevalence_grid</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#APP.prevalence_grid"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.APP.prevalence_grid"title="Link to this definition"></a></dt>
<dd><p>Generates vectors of prevalence values from an exhaustive grid of prevalence values. The
number of prevalence values explored for each dimension depends on <cite>n_prevalences</cite>, so that, if, for example,
<cite>n_prevalences=11</cite> then the prevalence values of the grid are taken from [0, 0.1, 0.2, …, 0.9, 1]. Only
valid prevalence distributions are returned, i.e., vectors of prevalence values that sum up to 1. For each
valid vector of prevalence values, <cite>repeat</cite> copies are returned. The vector of prevalence values can be
implicit (by setting <cite>return_constrained_dim=False</cite>), meaning that the last dimension (which is constrained
to 1 - sum of the rest) is not returned (note that, quite obviously, in this case the vector does not sum up to
1). Note that this method is deterministic, i.e., there is no random sampling anywhere.</p>
<spanclass="sig-name descname"><spanclass="pre">sample</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">index</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#APP.sample"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.APP.sample"title="Link to this definition"></a></dt>
<dd><p>Realizes the sample given the index of the instances.</p>
<spanclass="sig-name descname"><spanclass="pre">samples_parameters</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#APP.samples_parameters"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.APP.samples_parameters"title="Link to this definition"></a></dt>
<dd><p>Return all the necessary parameters to replicate the samples as according to the APP protocol.</p>
<spanclass="sig-name descname"><spanclass="pre">total</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#APP.total"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.APP.total"title="Link to this definition"></a></dt>
<dd><p>Returns the number of samples that will be generated</p>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.protocol.</span></span><spanclass="sig-name descname"><spanclass="pre">AbstractProtocol</span></span><aclass="reference internal"href="_modules/quapy/protocol.html#AbstractProtocol"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.AbstractProtocol"title="Link to this definition"></a></dt>
<spanclass="sig-name descname"><spanclass="pre">total</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#AbstractProtocol.total"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.AbstractProtocol.total"title="Link to this definition"></a></dt>
<dd><p>Indicates the total number of samples that the protocol generates.</p>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.protocol.</span></span><spanclass="sig-name descname"><spanclass="pre">AbstractStochasticSeededProtocol</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">random_state</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">0</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#AbstractStochasticSeededProtocol"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.AbstractStochasticSeededProtocol"title="Link to this definition"></a></dt>
<p>An <cite>AbstractStochasticSeededProtocol</cite> is a protocol that generates, via any random procedure (e.g.,
via random sampling), sequences of <aclass="reference internal"href="quapy.data.html#quapy.data.base.LabelledCollection"title="quapy.data.base.LabelledCollection"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.data.base.LabelledCollection</span></code></a> samples.
The protocol abstraction enforces
the object to be instantiated using a seed, so that the sequence can be fully replicated.
In order to make this functionality possible, the classes extending this abstraction need to
implement only two functions, <aclass="reference internal"href="#quapy.protocol.AbstractStochasticSeededProtocol.samples_parameters"title="quapy.protocol.AbstractStochasticSeededProtocol.samples_parameters"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">samples_parameters()</span></code></a> which generates all the parameters
needed for extracting the samples, and <aclass="reference internal"href="#quapy.protocol.AbstractStochasticSeededProtocol.sample"title="quapy.protocol.AbstractStochasticSeededProtocol.sample"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">sample()</span></code></a> that, given some parameters as input,
<spanclass="sig-name descname"><spanclass="pre">collator</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">sample</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">*</span></span><spanclass="n"><spanclass="pre">args</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#AbstractStochasticSeededProtocol.collator"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.AbstractStochasticSeededProtocol.collator"title="Link to this definition"></a></dt>
<dd><p>The collator prepares the sample to accommodate the desired output format before returning the output.
This collator simply returns the sample as it is. Classes inheriting from this abstract class can
<emclass="property"><spanclass="pre">property</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">random_state</span></span><aclass="headerlink"href="#quapy.protocol.AbstractStochasticSeededProtocol.random_state"title="Link to this definition"></a></dt>
<emclass="property"><spanclass="pre">abstract</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">sample</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">params</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#AbstractStochasticSeededProtocol.sample"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.AbstractStochasticSeededProtocol.sample"title="Link to this definition"></a></dt>
<dd><p>Extract one sample determined by the given parameters</p>
<emclass="property"><spanclass="pre">abstract</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">samples_parameters</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#AbstractStochasticSeededProtocol.samples_parameters"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.AbstractStochasticSeededProtocol.samples_parameters"title="Link to this definition"></a></dt>
<dd><p>This function has to return all the necessary parameters to replicate the samples</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.protocol.</span></span><spanclass="sig-name descname"><spanclass="pre">ArtificialPrevalenceProtocol</span></span><aclass="headerlink"href="#quapy.protocol.ArtificialPrevalenceProtocol"title="Link to this definition"></a></dt>
<dd><p>alias of <aclass="reference internal"href="#quapy.protocol.APP"title="quapy.protocol.APP"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">APP</span></code></a></p>
<li><p><strong>domainA</strong>– one domain, an object of <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">qp.data.LabelledCollection</span></code></p></li>
<li><p><strong>domainB</strong>– another domain, an object of <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">qp.data.LabelledCollection</span></code></p></li>
<li><p><strong>sample_size</strong>– integer, the number of instances in each sample; if None (default) then it is taken from
qp.environ[“SAMPLE_SIZE”]. If this is not set, a ValueError exception is raised.</p></li>
<li><p><strong>repeats</strong>– int, number of samples to draw for every mixture rate</p></li>
<li><p><strong>prevalence</strong>– the prevalence to preserv along the mixtures. If specified, should be an array containing
one prevalence value (positive float) for each class and summing up to one. If not specified, the prevalence
will be taken from the domain A (default).</p></li>
<li><p><strong>mixture_points</strong>– an integer indicating the number of points to take from a linear scale (e.g., 21 will
generate the mixture points [1, 0.95, 0.9, …, 0]), or the array of mixture values itself.
the specific points</p></li>
<li><p><strong>random_state</strong>– allows replicating samples across runs (default 0, meaning that the sequence of samples
will be the same every time the protocol is called)</p></li>
<spanclass="sig-name descname"><spanclass="pre">sample</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">indexes</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#DomainMixer.sample"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.DomainMixer.sample"title="Link to this definition"></a></dt>
<dd><p>Realizes the sample given a pair of indexes of the instances from A and B.</p>
<spanclass="sig-name descname"><spanclass="pre">samples_parameters</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#DomainMixer.samples_parameters"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.DomainMixer.samples_parameters"title="Link to this definition"></a></dt>
<dd><p>Return all the necessary parameters to replicate the samples as according to the this protocol.</p>
<spanclass="sig-name descname"><spanclass="pre">total</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#DomainMixer.total"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.DomainMixer.total"title="Link to this definition"></a></dt>
<dd><p>Returns the number of samples that will be generated (equals to “repeats * mixture_points”)</p>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.protocol.</span></span><spanclass="sig-name descname"><spanclass="pre">IterateProtocol</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="pre">samples:</span><spanclass="pre">[<class</span><spanclass="pre">'quapy.data.base.LabelledCollection'>]</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#IterateProtocol"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.IterateProtocol"title="Link to this definition"></a></dt>
<ddclass="field-odd"><p><strong>samples</strong>– a list of <aclass="reference internal"href="quapy.data.html#quapy.data.base.LabelledCollection"title="quapy.data.base.LabelledCollection"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.data.base.LabelledCollection</span></code></a></p>
<spanclass="sig-name descname"><spanclass="pre">total</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#IterateProtocol.total"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.IterateProtocol.total"title="Link to this definition"></a></dt>
<dd><p>Returns the number of samples in this protocol</p>
<spanclass="sig-name descname"><spanclass="pre">sample</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">index</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#NPP.sample"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.NPP.sample"title="Link to this definition"></a></dt>
<dd><p>Realizes the sample given the index of the instances.</p>
<spanclass="sig-name descname"><spanclass="pre">samples_parameters</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#NPP.samples_parameters"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.NPP.samples_parameters"title="Link to this definition"></a></dt>
<dd><p>Return all the necessary parameters to replicate the samples as according to the NPP protocol.</p>
<spanclass="sig-name descname"><spanclass="pre">total</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#NPP.total"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.NPP.total"title="Link to this definition"></a></dt>
<dd><p>Returns the number of samples that will be generated (equals to “repeats”)</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.protocol.</span></span><spanclass="sig-name descname"><spanclass="pre">NaturalPrevalenceProtocol</span></span><aclass="headerlink"href="#quapy.protocol.NaturalPrevalenceProtocol"title="Link to this definition"></a></dt>
<dd><p>alias of <aclass="reference internal"href="#quapy.protocol.NPP"title="quapy.protocol.NPP"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">NPP</span></code></a></p>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.protocol.</span></span><spanclass="sig-name descname"><spanclass="pre">OnLabelledCollectionProtocol</span></span><aclass="reference internal"href="_modules/quapy/protocol.html#OnLabelledCollectionProtocol"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.OnLabelledCollectionProtocol"title="Link to this definition"></a></dt>
<p>Protocols that generate samples from a <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">qp.data.LabelledCollection</span></code> object.</p>
<spanclass="sig-name descname"><spanclass="pre">RETURN_TYPES</span></span><emclass="property"><spanclass="w"></span><spanclass="p"><spanclass="pre">=</span></span><spanclass="w"></span><spanclass="pre">['sample_prev',</span><spanclass="pre">'labelled_collection',</span><spanclass="pre">'index']</span></em><aclass="headerlink"href="#quapy.protocol.OnLabelledCollectionProtocol.RETURN_TYPES"title="Link to this definition"></a></dt>
<emclass="property"><spanclass="pre">classmethod</span><spanclass="w"></span></em><spanclass="sig-name descname"><spanclass="pre">get_collator</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">return_type</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">'sample_prev'</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#OnLabelledCollectionProtocol.get_collator"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.OnLabelledCollectionProtocol.get_collator"title="Link to this definition"></a></dt>
<dd><p>Returns a collator function, i.e., a function that prepares the yielded data</p>
<spanclass="sig-name descname"><spanclass="pre">get_labelled_collection</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#OnLabelledCollectionProtocol.get_labelled_collection"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.OnLabelledCollectionProtocol.get_labelled_collection"title="Link to this definition"></a></dt>
<dd><p>Returns the labelled collection on which this protocol acts.</p>
<ddclass="field-odd"><p>an object of type <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">qp.data.LabelledCollection</span></code></p>
<spanclass="sig-name descname"><spanclass="pre">on_preclassified_instances</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">pre_classifications</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">in_place</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">False</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#OnLabelledCollectionProtocol.on_preclassified_instances"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.OnLabelledCollectionProtocol.on_preclassified_instances"title="Link to this definition"></a></dt>
<dd><p>Returns a copy of this protocol that acts on a modified version of the original
<codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">qp.data.LabelledCollection</span></code> in which the original instances have been replaced
with the outputs of a classifier for each instance. (This is convenient for speeding-up
the evaluation procedures for many samples, by pre-classifying the instances in advance.)</p>
<p>A variant of <aclass="reference internal"href="#quapy.protocol.APP"title="quapy.protocol.APP"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">APP</span></code></a> that, instead of using a grid of equidistant prevalence values,
relies on the Kraemer algorithm for sampling unit (k-1)-simplex uniformly at random, with
k the number of classes. This protocol covers the entire range of prevalence values in a
statistical sense, i.e., unlike APP there is no guarantee that it is covered precisely
equally for all classes, but it is preferred in cases in which the number of possible
combinations of the grid values of APP makes this endeavour intractable.</p>
<spanclass="sig-name descname"><spanclass="pre">sample</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">index</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#UPP.sample"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.UPP.sample"title="Link to this definition"></a></dt>
<dd><p>Realizes the sample given the index of the instances.</p>
<spanclass="sig-name descname"><spanclass="pre">samples_parameters</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#UPP.samples_parameters"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.UPP.samples_parameters"title="Link to this definition"></a></dt>
<dd><p>Return all the necessary parameters to replicate the samples as according to the UPP protocol.</p>
<spanclass="sig-name descname"><spanclass="pre">total</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/protocol.html#UPP.total"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.protocol.UPP.total"title="Link to this definition"></a></dt>
<dd><p>Returns the number of samples that will be generated (equals to “repeats”)</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.protocol.</span></span><spanclass="sig-name descname"><spanclass="pre">UniformPrevalenceProtocol</span></span><aclass="headerlink"href="#quapy.protocol.UniformPrevalenceProtocol"title="Link to this definition"></a></dt>
<dd><p>alias of <aclass="reference internal"href="#quapy.protocol.UPP"title="quapy.protocol.UPP"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">UPP</span></code></a></p>
<emclass="property"><spanclass="pre">class</span><spanclass="w"></span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">EarlyStop</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">patience</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">lower_is_better</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">True</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#EarlyStop"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.EarlyStop"title="Link to this definition"></a></dt>
<spanclass="gp">>>></span><spanclass="n">earlystop</span><spanclass="o">.</span><spanclass="n">IMPROVED</span><spanclass="c1"># is True</span>
<spanclass="gp">>>></span><spanclass="n">earlystop</span><spanclass="o">.</span><spanclass="n">STOP</span><spanclass="c1"># is False (patience=1)</span>
<spanclass="gp">>>></span><spanclass="n">earlystop</span><spanclass="o">.</span><spanclass="n">STOP</span><spanclass="c1"># is True (patience=0)</span>
<spanclass="gp">>>></span><spanclass="n">earlystop</span><spanclass="o">.</span><spanclass="n">best_epoch</span><spanclass="c1"># is 1</span>
<spanclass="gp">>>></span><spanclass="n">earlystop</span><spanclass="o">.</span><spanclass="n">best_score</span><spanclass="c1"># is 0.7</span>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">create_if_not_exist</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">path</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#create_if_not_exist"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.create_if_not_exist"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">create_parent_dir</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">path</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#create_parent_dir"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.create_parent_dir"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">download_file</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">url</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">archive_filename</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#download_file"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.download_file"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">download_file_if_not_exists</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">url</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">archive_filename</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#download_file_if_not_exists"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.download_file_if_not_exists"title="Link to this definition"></a></dt>
<dd><p>Dowloads a function (using <aclass="reference internal"href="#quapy.util.download_file"title="quapy.util.download_file"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">download_file()</span></code></a>) if the file does not exist.</p>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">get_quapy_home</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#get_quapy_home"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.get_quapy_home"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">map_parallel</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">func</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">args</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_jobs</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#map_parallel"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.map_parallel"title="Link to this definition"></a></dt>
<dd><p>Applies func to n_jobs slices of args. E.g., if args is an array of 99 items and n_jobs=2, then
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">pickled_resource</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">pickle_path</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">str</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">generation_func</span></span><spanclass="p"><spanclass="pre">:</span></span><spanclass="w"></span><spanclass="n"><spanclass="pre">callable</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">*</span></span><spanclass="n"><spanclass="pre">args</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#pickled_resource"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.pickled_resource"title="Link to this definition"></a></dt>
this function is invoked, it loads the pickled resource. Example:</p>
<divclass="doctest highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="gp">>>></span><spanclass="k">def</span><spanclass="nf">some_array</span><spanclass="p">(</span><spanclass="n">n</span><spanclass="p">):</span><spanclass="c1"># a mock resource created with one parameter (`n`)</span>
<spanclass="gp">>>></span><spanclass="n">pickled_resource</span><spanclass="p">(</span><spanclass="s1">'./my_array.pkl'</span><spanclass="p">,</span><spanclass="n">some_array</span><spanclass="p">,</span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="c1"># the resource does not exist: it is created by calling some_array(10)</span>
<spanclass="gp">>>></span><spanclass="n">pickled_resource</span><spanclass="p">(</span><spanclass="s1">'./my_array.pkl'</span><spanclass="p">,</span><spanclass="n">some_array</span><spanclass="p">,</span><spanclass="mi">10</span><spanclass="p">)</span><spanclass="c1"># the resource exists; it is loaded from './my_array.pkl'</span>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">save_text_file</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">path</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">text</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#save_text_file"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.save_text_file"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">temp_seed</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">random_state</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#temp_seed"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.temp_seed"title="Link to this definition"></a></dt>
<spanclass="sig-prename descclassname"><spanclass="pre">quapy.util.</span></span><spanclass="sig-name descname"><spanclass="pre">timeout</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">seconds</span></span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="_modules/quapy/util.html#timeout"><spanclass="viewcode-link"><spanclass="pre">[source]</span></span></a><aclass="headerlink"href="#quapy.util.timeout"title="Link to this definition"></a></dt>
<dd><p>Opens a context that will launch an exception if not closed after a given number of seconds</p>