forked from moreo/QuaPy
improving code quality in terms of pylint
This commit is contained in:
parent
de93cce391
commit
4904475d26
|
@ -224,8 +224,6 @@
|
||||||
<li><a href="quapy.html#quapy.util.create_parent_dir">create_parent_dir() (in module quapy.util)</a>
|
<li><a href="quapy.html#quapy.util.create_parent_dir">create_parent_dir() (in module quapy.util)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="quapy.method.html#quapy.method.aggregative.cross_generate_predictions">cross_generate_predictions() (in module quapy.method.aggregative)</a>
|
<li><a href="quapy.method.html#quapy.method.aggregative.cross_generate_predictions">cross_generate_predictions() (in module quapy.method.aggregative)</a>
|
||||||
</li>
|
|
||||||
<li><a href="quapy.method.html#quapy.method.aggregative.cross_generate_predictions_depr">cross_generate_predictions_depr() (in module quapy.method.aggregative)</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li><a href="quapy.html#quapy.model_selection.cross_val_predict">cross_val_predict() (in module quapy.model_selection)</a>
|
<li><a href="quapy.html#quapy.model_selection.cross_val_predict">cross_val_predict() (in module quapy.model_selection)</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
Binary file not shown.
|
@ -316,11 +316,14 @@ fitting <cite>TruncatedSVD</cite> and then <cite>LogisticRegression</cite> on th
|
||||||
|
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="quapy.classification.methods.LowRankLogisticRegression.get_params">
|
<dt class="sig sig-object py" id="quapy.classification.methods.LowRankLogisticRegression.get_params">
|
||||||
<span class="sig-name descname"><span class="pre">get_params</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#quapy.classification.methods.LowRankLogisticRegression.get_params" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-name descname"><span class="pre">get_params</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">deep</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.classification.methods.LowRankLogisticRegression.get_params" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Get hyper-parameters for this estimator.</p>
|
<dd><p>Get hyper-parameters for this estimator.</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><p>a dictionary with parameter names mapped to their values</p>
|
<dd class="field-odd"><p><strong>deep</strong> – compatibility with sklearn</p>
|
||||||
|
</dd>
|
||||||
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
<dd class="field-even"><p>a dictionary with parameter names mapped to their values</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
@ -524,7 +527,7 @@ dimensionality of the embedding</p>
|
||||||
|
|
||||||
<dl class="py class">
|
<dl class="py class">
|
||||||
<dt class="sig sig-object py" id="quapy.classification.neural.NeuralClassifierTrainer">
|
<dt class="sig sig-object py" id="quapy.classification.neural.NeuralClassifierTrainer">
|
||||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">quapy.classification.neural.</span></span><span class="sig-name descname"><span class="pre">NeuralClassifierTrainer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">net</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#quapy.classification.neural.TextClassifierNet" title="quapy.classification.neural.TextClassifierNet"><span class="pre">TextClassifierNet</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">lr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.001</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weight_decay</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">patience</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">epochs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">200</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">64</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_size_test</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">512</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">padding_length</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">300</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">device</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'cpu'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">checkpointpath</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'../checkpoint/classifier_net.dat'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.classification.neural.NeuralClassifierTrainer" title="Permalink to this definition">¶</a></dt>
|
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">quapy.classification.neural.</span></span><span class="sig-name descname"><span class="pre">NeuralClassifierTrainer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">net</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#quapy.classification.neural.TextClassifierNet" title="quapy.classification.neural.TextClassifierNet"><span class="pre">TextClassifierNet</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">lr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.001</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weight_decay</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">patience</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">epochs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">200</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">64</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">batch_size_test</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">512</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">padding_length</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">300</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">device</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'cuda'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">checkpointpath</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'../checkpoint/classifier_net.dat'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.classification.neural.NeuralClassifierTrainer" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||||||
<p>Trains a neural network for text classification.</p>
|
<p>Trains a neural network for text classification.</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
|
|
|
@ -447,8 +447,8 @@ index.</p>
|
||||||
<span class="sig-name descname"><span class="pre">sampling_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shuffle</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.data.base.LabelledCollection.sampling_index" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-name descname"><span class="pre">sampling_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shuffle</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.data.base.LabelledCollection.sampling_index" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Returns an index to be used to extract a random sample of desired size and desired prevalence values. If the
|
<dd><p>Returns an index to be used to extract a random sample of desired size and desired prevalence values. If the
|
||||||
prevalence values are not specified, then returns the index of a uniform sampling.
|
prevalence values are not specified, then returns the index of a uniform sampling.
|
||||||
For each class, the sampling is drawn without replacement if the requested prevalence is larger than
|
For each class, the sampling is drawn with replacement if the requested prevalence is larger than
|
||||||
the actual prevalence of the class, or with replacement otherwise.</p>
|
the actual prevalence of the class, or without replacement otherwise.</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
|
@ -534,7 +534,7 @@ values for each class)</p>
|
||||||
<dt class="sig sig-object py" id="quapy.data.base.LabelledCollection.uniform_sampling">
|
<dt class="sig sig-object py" id="quapy.data.base.LabelledCollection.uniform_sampling">
|
||||||
<span class="sig-name descname"><span class="pre">uniform_sampling</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.data.base.LabelledCollection.uniform_sampling" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-name descname"><span class="pre">uniform_sampling</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.data.base.LabelledCollection.uniform_sampling" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Returns a uniform sample (an instance of <a class="reference internal" href="#quapy.data.base.LabelledCollection" title="quapy.data.base.LabelledCollection"><code class="xref py py-class docutils literal notranslate"><span class="pre">LabelledCollection</span></code></a>) of desired size. The sampling is drawn
|
<dd><p>Returns a uniform sample (an instance of <a class="reference internal" href="#quapy.data.base.LabelledCollection" title="quapy.data.base.LabelledCollection"><code class="xref py py-class docutils literal notranslate"><span class="pre">LabelledCollection</span></code></a>) of desired size. The sampling is drawn
|
||||||
without replacement if the requested size is greater than the number of instances, or with replacement
|
with replacement if the requested size is greater than the number of instances, or without replacement
|
||||||
otherwise.</p>
|
otherwise.</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
|
@ -553,7 +553,7 @@ otherwise.</p>
|
||||||
<dt class="sig sig-object py" id="quapy.data.base.LabelledCollection.uniform_sampling_index">
|
<dt class="sig sig-object py" id="quapy.data.base.LabelledCollection.uniform_sampling_index">
|
||||||
<span class="sig-name descname"><span class="pre">uniform_sampling_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.data.base.LabelledCollection.uniform_sampling_index" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-name descname"><span class="pre">uniform_sampling_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.data.base.LabelledCollection.uniform_sampling_index" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Returns an index to be used to extract a uniform sample of desired size. The sampling is drawn
|
<dd><p>Returns an index to be used to extract a uniform sample of desired size. The sampling is drawn
|
||||||
without replacement if the requested size is greater than the number of instances, or with replacement
|
with replacement if the requested size is greater than the number of instances, or without replacement
|
||||||
otherwise.</p>
|
otherwise.</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
</section>
|
</section>
|
||||||
<section id="module-quapy.error">
|
<section id="module-quapy.error">
|
||||||
<span id="quapy-error"></span><h2>quapy.error<a class="headerlink" href="#module-quapy.error" title="Permalink to this heading">¶</a></h2>
|
<span id="quapy-error"></span><h2>quapy.error<a class="headerlink" href="#module-quapy.error" title="Permalink to this heading">¶</a></h2>
|
||||||
|
<p>Implementation of error measures used for quantification</p>
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.absolute_error">
|
<dt class="sig sig-object py" id="quapy.error.absolute_error">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">absolute_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.absolute_error" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">absolute_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.absolute_error" title="Permalink to this definition">¶</a></dt>
|
||||||
|
@ -86,8 +87,9 @@ where <span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.acc_error">
|
<dt class="sig sig-object py" id="quapy.error.acc_error">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">acc_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y_true</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_pred</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.acc_error" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">acc_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y_true</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_pred</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.acc_error" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Computes the error in terms of 1-accuracy. The accuracy is computed as <span class="math notranslate nohighlight">\(\frac{tp+tn}{tp+fp+fn+tn}\)</span>, with
|
<dd><p>Computes the error in terms of 1-accuracy. The accuracy is computed as
|
||||||
<cite>tp</cite>, <cite>fp</cite>, <cite>fn</cite>, and <cite>tn</cite> standing for true positives, false positives, false negatives, and true negatives,
|
<span class="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,
|
||||||
respectively</p>
|
respectively</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
|
@ -105,8 +107,9 @@ respectively</p>
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.acce">
|
<dt class="sig sig-object py" id="quapy.error.acce">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">acce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y_true</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_pred</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.acce" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">acce</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y_true</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_pred</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.acce" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Computes the error in terms of 1-accuracy. The accuracy is computed as <span class="math notranslate nohighlight">\(\frac{tp+tn}{tp+fp+fn+tn}\)</span>, with
|
<dd><p>Computes the error in terms of 1-accuracy. The accuracy is computed as
|
||||||
<cite>tp</cite>, <cite>fp</cite>, <cite>fn</cite>, and <cite>tn</cite> standing for true positives, false positives, false negatives, and true negatives,
|
<span class="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,
|
||||||
respectively</p>
|
respectively</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
|
@ -146,10 +149,12 @@ where <span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.f1_error">
|
<dt class="sig sig-object py" id="quapy.error.f1_error">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">f1_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y_true</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_pred</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.f1_error" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">f1_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y_true</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_pred</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.f1_error" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>F1 error: simply computes the error in terms of macro <span class="math notranslate nohighlight">\(F_1\)</span>, i.e., <span class="math notranslate nohighlight">\(1-F_1^M\)</span>,
|
<dd><p>F1 error: simply computes the error in terms of macro <span class="math notranslate nohighlight">\(F_1\)</span>, i.e.,
|
||||||
where <span class="math notranslate nohighlight">\(F_1\)</span> is the harmonic mean of precision and recall, defined as <span class="math notranslate nohighlight">\(\frac{2tp}{2tp+fp+fn}\)</span>,
|
<span class="math notranslate nohighlight">\(1-F_1^M\)</span>, where <span class="math notranslate nohighlight">\(F_1\)</span> is the harmonic mean of precision and recall,
|
||||||
with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing for true positives, false positives, and false negatives, respectively.
|
defined as <span class="math notranslate nohighlight">\(\frac{2tp}{2tp+fp+fn}\)</span>, with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing
|
||||||
<cite>Macro</cite> averaging means the <span class="math notranslate nohighlight">\(F_1\)</span> is computed for each category independently, and then averaged.</p>
|
for true positives, false positives, and false negatives, respectively.
|
||||||
|
<cite>Macro</cite> averaging means the <span class="math notranslate nohighlight">\(F_1\)</span> is computed for each category independently,
|
||||||
|
and then averaged.</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
|
@ -166,10 +171,12 @@ with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing for true pos
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.f1e">
|
<dt class="sig sig-object py" id="quapy.error.f1e">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">f1e</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y_true</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_pred</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.f1e" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">f1e</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">y_true</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">y_pred</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.f1e" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>F1 error: simply computes the error in terms of macro <span class="math notranslate nohighlight">\(F_1\)</span>, i.e., <span class="math notranslate nohighlight">\(1-F_1^M\)</span>,
|
<dd><p>F1 error: simply computes the error in terms of macro <span class="math notranslate nohighlight">\(F_1\)</span>, i.e.,
|
||||||
where <span class="math notranslate nohighlight">\(F_1\)</span> is the harmonic mean of precision and recall, defined as <span class="math notranslate nohighlight">\(\frac{2tp}{2tp+fp+fn}\)</span>,
|
<span class="math notranslate nohighlight">\(1-F_1^M\)</span>, where <span class="math notranslate nohighlight">\(F_1\)</span> is the harmonic mean of precision and recall,
|
||||||
with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing for true positives, false positives, and false negatives, respectively.
|
defined as <span class="math notranslate nohighlight">\(\frac{2tp}{2tp+fp+fn}\)</span>, with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing
|
||||||
<cite>Macro</cite> averaging means the <span class="math notranslate nohighlight">\(F_1\)</span> is computed for each category independently, and then averaged.</p>
|
for true positives, false positives, and false negatives, respectively.
|
||||||
|
<cite>Macro</cite> averaging means the <span class="math notranslate nohighlight">\(F_1\)</span> is computed for each category independently,
|
||||||
|
and then averaged.</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
|
@ -186,7 +193,8 @@ with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing for true pos
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.from_name">
|
<dt class="sig sig-object py" id="quapy.error.from_name">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">from_name</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">err_name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.from_name" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">from_name</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">err_name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.from_name" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Gets an error function from its name. E.g., <cite>from_name(“mae”)</cite> will return function <a class="reference internal" href="#quapy.error.mae" title="quapy.error.mae"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.mae()</span></code></a></p>
|
<dd><p>Gets an error function from its name. E.g., <cite>from_name(“mae”)</cite>
|
||||||
|
will return function <a class="reference internal" href="#quapy.error.mae" title="quapy.error.mae"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.mae()</span></code></a></p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><p><strong>err_name</strong> – string, the error name</p>
|
<dd class="field-odd"><p><strong>err_name</strong> – string, the error name</p>
|
||||||
|
@ -199,11 +207,13 @@ with <cite>tp</cite>, <cite>fp</cite>, and <cite>fn</cite> standing for true pos
|
||||||
|
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.kld">
|
<dt class="sig sig-object py" id="quapy.error.kld">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">kld</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.kld" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">kld</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.kld" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><dl class="simple">
|
<dd><dl class="simple">
|
||||||
<dt>Computes the Kullback-Leibler divergence between the two prevalence distributions.</dt><dd><p>Kullback-Leibler divergence between two prevalence distributions <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
|
<dt>Computes the Kullback-Leibler divergence between the two prevalence distributions.</dt><dd><p>Kullback-Leibler divergence between two prevalence distributions <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span>
|
||||||
<span class="math notranslate nohighlight">\(KLD(p,\hat{p})=D_{KL}(p||\hat{p})=\sum_{y\in \mathcal{Y}} p(y)\log\frac{p(y)}{\hat{p}(y)}\)</span>, where
|
is computed as
|
||||||
<span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
|
<span class="math notranslate nohighlight">\(KLD(p,\hat{p})=D_{KL}(p||\hat{p})=
|
||||||
|
\sum_{y\in \mathcal{Y}} p(y)\log\frac{p(y)}{\hat{p}(y)}\)</span>,
|
||||||
|
where <span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
|
||||||
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
@ -212,9 +222,10 @@ The distributions are smoothed using the <cite>eps</cite> factor (see <a class="
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<li><p><strong>prevs</strong> – array-like of shape <cite>(n_classes,)</cite> with the true prevalence values</p></li>
|
<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>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. KLD is not defined in cases in which the distributions contain zeros; <cite>eps</cite>
|
<li><p><strong>eps</strong> – smoothing factor. KLD is not defined in cases in which the distributions contain
|
||||||
is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size. If <cite>eps=None</cite>, the sample size
|
zeros; <cite>eps</cite> is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size.
|
||||||
will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
|
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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -231,7 +242,8 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<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</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>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted
|
||||||
|
prevalence values</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -248,7 +260,8 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<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</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>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted
|
||||||
|
prevalence values</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -259,17 +272,21 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
|
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.mean_relative_absolute_error">
|
<dt class="sig sig-object py" id="quapy.error.mean_relative_absolute_error">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">mean_relative_absolute_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.mean_relative_absolute_error" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">mean_relative_absolute_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.mean_relative_absolute_error" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Computes the mean relative absolute error (see <a class="reference internal" href="#quapy.error.rae" title="quapy.error.rae"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.rae()</span></code></a>) across the sample pairs.
|
<dd><p>Computes the mean relative absolute error (see <a class="reference internal" href="#quapy.error.rae" title="quapy.error.rae"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.rae()</span></code></a>) across
|
||||||
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
the sample pairs. The distributions are smoothed using the <cite>eps</cite> factor (see
|
||||||
|
<a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<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</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the true
|
||||||
<li><p><strong>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted prevalence values</p></li>
|
prevalence values</p></li>
|
||||||
<li><p><strong>eps</strong> – smoothing factor. <cite>mrae</cite> is not defined in cases in which the true distribution contains zeros; <cite>eps</cite>
|
<li><p><strong>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted
|
||||||
is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size. If <cite>eps=None</cite>, the sample size
|
prevalence values</p></li>
|
||||||
will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
|
<li><p><strong>eps</strong> – smoothing factor. <cite>mrae</cite> is not defined in cases in which the true
|
||||||
|
distribution contains zeros; <cite>eps</cite> is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>,
|
||||||
|
with <span class="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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -281,16 +298,20 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.mkld">
|
<dt class="sig sig-object py" id="quapy.error.mkld">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">mkld</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.mkld" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">mkld</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.mkld" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Computes the mean Kullback-Leibler divergence (see <a class="reference internal" href="#quapy.error.kld" title="quapy.error.kld"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.kld()</span></code></a>) across the sample pairs.
|
<dd><p>Computes the mean Kullback-Leibler divergence (see <a class="reference internal" href="#quapy.error.kld" title="quapy.error.kld"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.kld()</span></code></a>) across the
|
||||||
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
sample pairs. The distributions are smoothed using the <cite>eps</cite> factor
|
||||||
|
(see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<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</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the true
|
||||||
<li><p><strong>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted prevalence values</p></li>
|
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>
|
<li><p><strong>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted
|
||||||
is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size. If <cite>eps=None</cite>, the sample size
|
prevalence values</p></li>
|
||||||
will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</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 <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -302,16 +323,19 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.mnkld">
|
<dt class="sig sig-object py" id="quapy.error.mnkld">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">mnkld</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.mnkld" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">mnkld</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.mnkld" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Computes the mean Normalized Kullback-Leibler divergence (see <a class="reference internal" href="#quapy.error.nkld" title="quapy.error.nkld"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.nkld()</span></code></a>) across the sample pairs.
|
<dd><p>Computes the mean Normalized Kullback-Leibler divergence (see <a class="reference internal" href="#quapy.error.nkld" title="quapy.error.nkld"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.nkld()</span></code></a>)
|
||||||
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
across the sample pairs. The distributions are smoothed using the <cite>eps</cite> factor
|
||||||
|
(see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<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</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>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted
|
||||||
<li><p><strong>eps</strong> – smoothing factor. NKLD is not defined in cases in which the distributions contain zeros; <cite>eps</cite>
|
prevalence values</p></li>
|
||||||
is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size. If <cite>eps=None</cite>, the sample size
|
<li><p><strong>eps</strong> – smoothing factor. NKLD is not defined in cases in which the distributions contain
|
||||||
will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
|
zeros; <cite>eps</cite> is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -322,17 +346,21 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
|
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.mrae">
|
<dt class="sig sig-object py" id="quapy.error.mrae">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">mrae</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.mrae" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">mrae</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.mrae" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Computes the mean relative absolute error (see <a class="reference internal" href="#quapy.error.rae" title="quapy.error.rae"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.rae()</span></code></a>) across the sample pairs.
|
<dd><p>Computes the mean relative absolute error (see <a class="reference internal" href="#quapy.error.rae" title="quapy.error.rae"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.rae()</span></code></a>) across
|
||||||
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
the sample pairs. The distributions are smoothed using the <cite>eps</cite> factor (see
|
||||||
|
<a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<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</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the true
|
||||||
<li><p><strong>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted prevalence values</p></li>
|
prevalence values</p></li>
|
||||||
<li><p><strong>eps</strong> – smoothing factor. <cite>mrae</cite> is not defined in cases in which the true distribution contains zeros; <cite>eps</cite>
|
<li><p><strong>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted
|
||||||
is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size. If <cite>eps=None</cite>, the sample size
|
prevalence values</p></li>
|
||||||
will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
|
<li><p><strong>eps</strong> – smoothing factor. <cite>mrae</cite> is not defined in cases in which the true
|
||||||
|
distribution contains zeros; <cite>eps</cite> is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>,
|
||||||
|
with <span class="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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -348,8 +376,10 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<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</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the
|
||||||
<li><p><strong>prevs_hat</strong> – array-like of shape <cite>(n_samples, n_classes,)</cite> with the predicted prevalence values</p></li>
|
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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -360,10 +390,12 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
|
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.nkld">
|
<dt class="sig sig-object py" id="quapy.error.nkld">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">nkld</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.nkld" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">nkld</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.nkld" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><dl class="simple">
|
<dd><dl class="simple">
|
||||||
<dt>Computes the Normalized Kullback-Leibler divergence between the two prevalence distributions.</dt><dd><p>Normalized Kullback-Leibler divergence between two prevalence distributions <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span>
|
<dt>Computes the Normalized Kullback-Leibler divergence between the two prevalence distributions.</dt><dd><p>Normalized Kullback-Leibler divergence between two prevalence distributions <span class="math notranslate nohighlight">\(p\)</span> and
|
||||||
is computed as <span class="math notranslate nohighlight">\(NKLD(p,\hat{p}) = 2\frac{e^{KLD(p,\hat{p})}}{e^{KLD(p,\hat{p})}+1}-1\)</span>, where
|
<span class="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
|
||||||
|
math:<cite>NKLD(p,hat{p}) = 2frac{e^{KLD(p,hat{p})}}{e^{KLD(p,hat{p})}+1}-1</cite>,
|
||||||
|
where
|
||||||
<span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
|
<span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
|
||||||
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
@ -373,9 +405,10 @@ The distributions are smoothed using the <cite>eps</cite> factor (see <a class="
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<li><p><strong>prevs</strong> – array-like of shape <cite>(n_classes,)</cite> with the true prevalence values</p></li>
|
<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>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. NKLD is not defined in cases in which the distributions contain zeros; <cite>eps</cite>
|
<li><p><strong>eps</strong> – smoothing factor. NKLD is not defined in cases in which the distributions
|
||||||
is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size. If <cite>eps=None</cite>, the sample size
|
contain zeros; <cite>eps</cite> is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample
|
||||||
will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
|
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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -386,10 +419,12 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
|
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.rae">
|
<dt class="sig sig-object py" id="quapy.error.rae">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">rae</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.rae" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">rae</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.rae" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><dl class="simple">
|
<dd><dl class="simple">
|
||||||
<dt>Computes the absolute relative error between the two prevalence vectors.</dt><dd><p>Relative absolute error between two prevalence vectors <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
|
<dt>Computes the absolute relative error between the two prevalence vectors.</dt><dd><p>Relative absolute error between two prevalence vectors <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span>
|
||||||
<span class="math notranslate nohighlight">\(RAE(p,\hat{p})=\frac{1}{|\mathcal{Y}|}\sum_{y\in \mathcal{Y}}\frac{|\hat{p}(y)-p(y)|}{p(y)}\)</span>,
|
is computed as
|
||||||
|
<span class="math notranslate nohighlight">\(RAE(p,\hat{p})=
|
||||||
|
\frac{1}{|\mathcal{Y}|}\sum_{y\in \mathcal{Y}}\frac{|\hat{p}(y)-p(y)|}{p(y)}\)</span>,
|
||||||
where <span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
|
where <span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
|
||||||
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
@ -399,9 +434,10 @@ The distributions are smoothed using the <cite>eps</cite> factor (see <a class="
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<li><p><strong>prevs</strong> – array-like of shape <cite>(n_classes,)</cite> with the true prevalence values</p></li>
|
<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>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>
|
<li><p><strong>eps</strong> – smoothing factor. <cite>rae</cite> is not defined in cases in which the true distribution
|
||||||
is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size. If <cite>eps=None</cite>, the sample size
|
contains zeros; <cite>eps</cite> is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the
|
||||||
will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
|
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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -412,10 +448,12 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
|
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.relative_absolute_error">
|
<dt class="sig sig-object py" id="quapy.error.relative_absolute_error">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">relative_absolute_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.relative_absolute_error" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">relative_absolute_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.relative_absolute_error" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><dl class="simple">
|
<dd><dl class="simple">
|
||||||
<dt>Computes the absolute relative error between the two prevalence vectors.</dt><dd><p>Relative absolute error between two prevalence vectors <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
|
<dt>Computes the absolute relative error between the two prevalence vectors.</dt><dd><p>Relative absolute error between two prevalence vectors <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span>
|
||||||
<span class="math notranslate nohighlight">\(RAE(p,\hat{p})=\frac{1}{|\mathcal{Y}|}\sum_{y\in \mathcal{Y}}\frac{|\hat{p}(y)-p(y)|}{p(y)}\)</span>,
|
is computed as
|
||||||
|
<span class="math notranslate nohighlight">\(RAE(p,\hat{p})=
|
||||||
|
\frac{1}{|\mathcal{Y}|}\sum_{y\in \mathcal{Y}}\frac{|\hat{p}(y)-p(y)|}{p(y)}\)</span>,
|
||||||
where <span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
|
where <span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.
|
||||||
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
The distributions are smoothed using the <cite>eps</cite> factor (see <a class="reference internal" href="#quapy.error.smooth" title="quapy.error.smooth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">quapy.error.smooth()</span></code></a>).</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
@ -425,9 +463,10 @@ The distributions are smoothed using the <cite>eps</cite> factor (see <a class="
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
<li><p><strong>prevs</strong> – array-like of shape <cite>(n_classes,)</cite> with the true prevalence values</p></li>
|
<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>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>
|
<li><p><strong>eps</strong> – smoothing factor. <cite>rae</cite> is not defined in cases in which the true distribution
|
||||||
is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the sample size. If <cite>eps=None</cite>, the sample size
|
contains zeros; <cite>eps</cite> is typically set to be <span class="math notranslate nohighlight">\(\frac{1}{2T}\)</span>, with <span class="math notranslate nohighlight">\(T\)</span> the
|
||||||
will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has thus to be set beforehand).</p></li>
|
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>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||||
|
@ -438,10 +477,11 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
|
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.error.se">
|
<dt class="sig sig-object py" id="quapy.error.se">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">se</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">p</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p_hat</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.se" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">se</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prevs_hat</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.se" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><dl class="simple">
|
<dd><dl class="simple">
|
||||||
<dt>Computes the squared error between the two prevalence vectors.</dt><dd><p>Squared error between two prevalence vectors <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
|
<dt>Computes the squared error between the two prevalence vectors.</dt><dd><p>Squared error between two prevalence vectors <span class="math notranslate nohighlight">\(p\)</span> and <span class="math notranslate nohighlight">\(\hat{p}\)</span> is computed as
|
||||||
<span class="math notranslate nohighlight">\(SE(p,\hat{p})=\frac{1}{|\mathcal{Y}|}\sum_{y\in \mathcal{Y}}(\hat{p}(y)-p(y))^2\)</span>, where
|
<span class="math notranslate nohighlight">\(SE(p,\hat{p})=\frac{1}{|\mathcal{Y}|}\sum_{y\in \mathcal{Y}}(\hat{p}(y)-p(y))^2\)</span>,
|
||||||
|
where
|
||||||
<span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.</p>
|
<span class="math notranslate nohighlight">\(\mathcal{Y}\)</span> are the classes of interest.</p>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
@ -462,7 +502,8 @@ will be taken from the environment variable <cite>SAMPLE_SIZE</cite> (which has
|
||||||
<dt class="sig sig-object py" id="quapy.error.smooth">
|
<dt class="sig sig-object py" id="quapy.error.smooth">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">smooth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.smooth" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.error.</span></span><span class="sig-name descname"><span class="pre">smooth</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prevs</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eps</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.error.smooth" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Smooths a prevalence distribution with <span class="math notranslate nohighlight">\(\epsilon\)</span> (<cite>eps</cite>) as:
|
<dd><p>Smooths a prevalence distribution with <span class="math notranslate nohighlight">\(\epsilon\)</span> (<cite>eps</cite>) as:
|
||||||
<span class="math notranslate nohighlight">\(\underline{p}(y)=\frac{\epsilon+p(y)}{\epsilon|\mathcal{Y}|+\displaystyle\sum_{y\in \mathcal{Y}}p(y)}\)</span></p>
|
<span class="math notranslate nohighlight">\(\underline{p}(y)=\frac{\epsilon+p(y)}{\epsilon|\mathcal{Y}|+
|
||||||
|
\displaystyle\sum_{y\in \mathcal{Y}}p(y)}\)</span></p>
|
||||||
<dl class="field-list simple">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||||
<dd class="field-odd"><ul class="simple">
|
<dd class="field-odd"><ul class="simple">
|
||||||
|
@ -601,7 +642,7 @@ convenient or not. Set to False to deactivate.</p></li>
|
||||||
</div>
|
</div>
|
||||||
<span class="target" id="module-quapy.protocol"></span><dl class="py class">
|
<span class="target" id="module-quapy.protocol"></span><dl class="py class">
|
||||||
<dt class="sig sig-object py" id="quapy.protocol.APP">
|
<dt class="sig sig-object py" id="quapy.protocol.APP">
|
||||||
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">quapy.protocol.</span></span><span class="sig-name descname"><span class="pre">APP</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="quapy.data.html#quapy.data.base.LabelledCollection" title="quapy.data.base.LabelledCollection"><span class="pre">LabelledCollection</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">sample_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_prevalences</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">21</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">repeats</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">smooth_limits_epsilon</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'sample_prev'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.protocol.APP" title="Permalink to this definition">¶</a></dt>
|
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">quapy.protocol.</span></span><span class="sig-name descname"><span class="pre">APP</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="quapy.data.html#quapy.data.base.LabelledCollection" title="quapy.data.base.LabelledCollection"><span class="pre">LabelledCollection</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">sample_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_prevalences</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">21</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">repeats</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">smooth_limits_epsilon</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">random_state</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sanity_check</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">return_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'sample_prev'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.protocol.APP" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Bases: <a class="reference internal" href="#quapy.protocol.AbstractStochasticSeededProtocol" title="quapy.protocol.AbstractStochasticSeededProtocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">AbstractStochasticSeededProtocol</span></code></a>, <a class="reference internal" href="#quapy.protocol.OnLabelledCollectionProtocol" title="quapy.protocol.OnLabelledCollectionProtocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">OnLabelledCollectionProtocol</span></code></a></p>
|
<dd><p>Bases: <a class="reference internal" href="#quapy.protocol.AbstractStochasticSeededProtocol" title="quapy.protocol.AbstractStochasticSeededProtocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">AbstractStochasticSeededProtocol</span></code></a>, <a class="reference internal" href="#quapy.protocol.OnLabelledCollectionProtocol" title="quapy.protocol.OnLabelledCollectionProtocol"><code class="xref py py-class docutils literal notranslate"><span class="pre">OnLabelledCollectionProtocol</span></code></a></p>
|
||||||
<p>Implementation of the artificial prevalence protocol (APP).
|
<p>Implementation of the artificial prevalence protocol (APP).
|
||||||
The APP consists of exploring a grid of prevalence values containing <cite>n_prevalences</cite> points (e.g.,
|
The APP consists of exploring a grid of prevalence values containing <cite>n_prevalences</cite> points (e.g.,
|
||||||
|
@ -621,6 +662,8 @@ grid (default is 21)</p></li>
|
||||||
<li><p><strong>smooth_limits_epsilon</strong> – the quantity to add and subtract to the limits 0 and 1</p></li>
|
<li><p><strong>smooth_limits_epsilon</strong> – the quantity to add and subtract to the limits 0 and 1</p></li>
|
||||||
<li><p><strong>random_state</strong> – allows replicating samples across runs (default 0, meaning that the sequence of samples
|
<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>
|
will be the same every time the protocol is called)</p></li>
|
||||||
|
<li><p><strong>sanity_check</strong> – int, raises an exception warning the user that the number of examples to be generated exceed
|
||||||
|
this number; set to None for skipping this check</p></li>
|
||||||
<li><p><strong>return_type</strong> – set to “sample_prev” (default) to get the pairs of (sample, prevalence) at each iteration, or
|
<li><p><strong>return_type</strong> – set to “sample_prev” (default) to get the pairs of (sample, prevalence) at each iteration, or
|
||||||
to “labelled_collection” to get instead instances of LabelledCollection</p></li>
|
to “labelled_collection” to get instead instances of LabelledCollection</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -1819,6 +1862,7 @@ this function is invoked, it loads the pickled resource. Example:</p>
|
||||||
</section>
|
</section>
|
||||||
<section id="module-quapy">
|
<section id="module-quapy">
|
||||||
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-quapy" title="Permalink to this heading">¶</a></h2>
|
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-quapy" title="Permalink to this heading">¶</a></h2>
|
||||||
|
<p>QuaPy module for quantification</p>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -1064,11 +1064,6 @@ validation data, or as an integer, indicating that the misclassification rates s
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.method.aggregative.</span></span><span class="sig-name descname"><span class="pre">cross_generate_predictions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">classifier</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_split</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">probabilistic</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fit_classifier</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_jobs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.method.aggregative.cross_generate_predictions" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.method.aggregative.</span></span><span class="sig-name descname"><span class="pre">cross_generate_predictions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">classifier</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_split</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">probabilistic</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fit_classifier</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n_jobs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.method.aggregative.cross_generate_predictions" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd></dd></dl>
|
<dd></dd></dl>
|
||||||
|
|
||||||
<dl class="py function">
|
|
||||||
<dt class="sig sig-object py" id="quapy.method.aggregative.cross_generate_predictions_depr">
|
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.method.aggregative.</span></span><span class="sig-name descname"><span class="pre">cross_generate_predictions_depr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">classifier</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_split</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">probabilistic</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fit_classifier</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method_name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.method.aggregative.cross_generate_predictions_depr" title="Permalink to this definition">¶</a></dt>
|
|
||||||
<dd></dd></dl>
|
|
||||||
|
|
||||||
<dl class="py function">
|
<dl class="py function">
|
||||||
<dt class="sig sig-object py" id="quapy.method.aggregative.newELM">
|
<dt class="sig sig-object py" id="quapy.method.aggregative.newELM">
|
||||||
<span class="sig-prename descclassname"><span class="pre">quapy.method.aggregative.</span></span><span class="sig-name descname"><span class="pre">newELM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">svmperf_base</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">loss</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'01'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">C</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.method.aggregative.newELM" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">quapy.method.aggregative.</span></span><span class="sig-name descname"><span class="pre">newELM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">svmperf_base</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">loss</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'01'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">C</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#quapy.method.aggregative.newELM" title="Permalink to this definition">¶</a></dt>
|
||||||
|
|
File diff suppressed because one or more lines are too long
237
quapy/error.py
237
quapy/error.py
|
@ -1,10 +1,13 @@
|
||||||
import quapy as qp
|
"""Implementation of error measures used for quantification"""
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from sklearn.metrics import f1_score
|
from sklearn.metrics import f1_score
|
||||||
|
import quapy as qp
|
||||||
|
|
||||||
|
|
||||||
def from_name(err_name):
|
def from_name(err_name):
|
||||||
"""Gets an error function from its name. E.g., `from_name("mae")` will return function :meth:`quapy.error.mae`
|
"""Gets an error function from its name. E.g., `from_name("mae")`
|
||||||
|
will return function :meth:`quapy.error.mae`
|
||||||
|
|
||||||
:param err_name: string, the error name
|
:param err_name: string, the error name
|
||||||
:return: a callable implementing the requested error
|
:return: a callable implementing the requested error
|
||||||
|
@ -15,10 +18,12 @@ def from_name(err_name):
|
||||||
|
|
||||||
|
|
||||||
def f1e(y_true, y_pred):
|
def f1e(y_true, y_pred):
|
||||||
"""F1 error: simply computes the error in terms of macro :math:`F_1`, i.e., :math:`1-F_1^M`,
|
"""F1 error: simply computes the error in terms of macro :math:`F_1`, i.e.,
|
||||||
where :math:`F_1` is the harmonic mean of precision and recall, defined as :math:`\\frac{2tp}{2tp+fp+fn}`,
|
:math:`1-F_1^M`, where :math:`F_1` is the harmonic mean of precision and recall,
|
||||||
with `tp`, `fp`, and `fn` standing for true positives, false positives, and false negatives, respectively.
|
defined as :math:`\\frac{2tp}{2tp+fp+fn}`, with `tp`, `fp`, and `fn` standing
|
||||||
`Macro` averaging means the :math:`F_1` is computed for each category independently, and then averaged.
|
for true positives, false positives, and false negatives, respectively.
|
||||||
|
`Macro` averaging means the :math:`F_1` is computed for each category independently,
|
||||||
|
and then averaged.
|
||||||
|
|
||||||
:param y_true: array-like of true labels
|
:param y_true: array-like of true labels
|
||||||
:param y_pred: array-like of predicted labels
|
:param y_pred: array-like of predicted labels
|
||||||
|
@ -28,8 +33,9 @@ def f1e(y_true, y_pred):
|
||||||
|
|
||||||
|
|
||||||
def acce(y_true, y_pred):
|
def acce(y_true, y_pred):
|
||||||
"""Computes the error in terms of 1-accuracy. The accuracy is computed as :math:`\\frac{tp+tn}{tp+fp+fn+tn}`, with
|
"""Computes the error in terms of 1-accuracy. The accuracy is computed as
|
||||||
`tp`, `fp`, `fn`, and `tn` standing for true positives, false positives, false negatives, and true negatives,
|
:math:`\\frac{tp+tn}{tp+fp+fn+tn}`, with `tp`, `fp`, `fn`, and `tn` standing
|
||||||
|
for true positives, false positives, false negatives, and true negatives,
|
||||||
respectively
|
respectively
|
||||||
|
|
||||||
:param y_true: array-like of true labels
|
:param y_true: array-like of true labels
|
||||||
|
@ -43,7 +49,8 @@ def mae(prevs, prevs_hat):
|
||||||
"""Computes the mean absolute error (see :meth:`quapy.error.ae`) across the sample pairs.
|
"""Computes the mean absolute error (see :meth:`quapy.error.ae`) across the sample pairs.
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true prevalence values
|
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true prevalence values
|
||||||
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted prevalence values
|
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted
|
||||||
|
prevalence values
|
||||||
:return: mean absolute error
|
:return: mean absolute error
|
||||||
"""
|
"""
|
||||||
return ae(prevs, prevs_hat).mean()
|
return ae(prevs, prevs_hat).mean()
|
||||||
|
@ -52,7 +59,7 @@ def mae(prevs, prevs_hat):
|
||||||
def ae(prevs, prevs_hat):
|
def ae(prevs, prevs_hat):
|
||||||
"""Computes the absolute error between the two prevalence vectors.
|
"""Computes the absolute error between the two prevalence vectors.
|
||||||
Absolute error between two prevalence vectors :math:`p` and :math:`\\hat{p}` is computed as
|
Absolute error between two prevalence vectors :math:`p` and :math:`\\hat{p}` is computed as
|
||||||
:math:`AE(p,\\hat{p})=\\frac{1}{|\\mathcal{Y}|}\\sum_{y\in \mathcal{Y}}|\\hat{p}(y)-p(y)|`,
|
:math:`AE(p,\\hat{p})=\\frac{1}{|\\mathcal{Y}|}\\sum_{y\\in \\mathcal{Y}}|\\hat{p}(y)-p(y)|`,
|
||||||
where :math:`\\mathcal{Y}` are the classes of interest.
|
where :math:`\\mathcal{Y}` are the classes of interest.
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
||||||
|
@ -66,129 +73,153 @@ def ae(prevs, prevs_hat):
|
||||||
def mse(prevs, prevs_hat):
|
def mse(prevs, prevs_hat):
|
||||||
"""Computes the mean squared error (see :meth:`quapy.error.se`) across the sample pairs.
|
"""Computes the mean squared error (see :meth:`quapy.error.se`) across the sample pairs.
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true prevalence values
|
:param prevs: array-like of shape `(n_samples, n_classes,)` with the
|
||||||
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted prevalence values
|
true prevalence values
|
||||||
|
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the
|
||||||
|
predicted prevalence values
|
||||||
:return: mean squared error
|
:return: mean squared error
|
||||||
"""
|
"""
|
||||||
return se(prevs, prevs_hat).mean()
|
return se(prevs, prevs_hat).mean()
|
||||||
|
|
||||||
|
|
||||||
def se(p, p_hat):
|
def se(prevs, prevs_hat):
|
||||||
"""Computes the squared error between the two prevalence vectors.
|
"""Computes the squared error between the two prevalence vectors.
|
||||||
Squared error between two prevalence vectors :math:`p` and :math:`\\hat{p}` is computed as
|
Squared error between two prevalence vectors :math:`p` and :math:`\\hat{p}` is computed as
|
||||||
:math:`SE(p,\\hat{p})=\\frac{1}{|\\mathcal{Y}|}\\sum_{y\in \mathcal{Y}}(\\hat{p}(y)-p(y))^2`, where
|
:math:`SE(p,\\hat{p})=\\frac{1}{|\\mathcal{Y}|}\\sum_{y\\in \\mathcal{Y}}(\\hat{p}(y)-p(y))^2`,
|
||||||
|
where
|
||||||
:math:`\\mathcal{Y}` are the classes of interest.
|
:math:`\\mathcal{Y}` are the classes of interest.
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
||||||
:param prevs_hat: array-like of shape `(n_classes,)` with the predicted prevalence values
|
:param prevs_hat: array-like of shape `(n_classes,)` with the predicted prevalence values
|
||||||
:return: absolute error
|
:return: absolute error
|
||||||
"""
|
"""
|
||||||
return ((p_hat-p)**2).mean(axis=-1)
|
return ((prevs_hat - prevs) ** 2).mean(axis=-1)
|
||||||
|
|
||||||
|
|
||||||
def mkld(prevs, prevs_hat, eps=None):
|
def mkld(prevs, prevs_hat, eps=None):
|
||||||
"""Computes the mean Kullback-Leibler divergence (see :meth:`quapy.error.kld`) across the sample pairs.
|
"""Computes the mean Kullback-Leibler divergence (see :meth:`quapy.error.kld`) across the
|
||||||
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
sample pairs. The distributions are smoothed using the `eps` factor
|
||||||
|
(see :meth:`quapy.error.smooth`).
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true prevalence values
|
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true
|
||||||
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted prevalence values
|
prevalence values
|
||||||
:param eps: smoothing factor. KLD is not defined in cases in which the distributions contain zeros; `eps`
|
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted
|
||||||
is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size. If `eps=None`, the sample size
|
prevalence values
|
||||||
will be taken from the environment variable `SAMPLE_SIZE` (which has thus to be set beforehand).
|
:param eps: smoothing factor. KLD is not defined in cases in which the distributions contain
|
||||||
|
zeros; `eps` is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size.
|
||||||
|
If `eps=None`, the sample size will be taken from the environment variable `SAMPLE_SIZE`
|
||||||
|
(which has thus to be set beforehand).
|
||||||
:return: mean Kullback-Leibler distribution
|
:return: mean Kullback-Leibler distribution
|
||||||
"""
|
"""
|
||||||
return kld(prevs, prevs_hat, eps).mean()
|
return kld(prevs, prevs_hat, eps).mean()
|
||||||
|
|
||||||
|
|
||||||
def kld(p, p_hat, eps=None):
|
def kld(prevs, prevs_hat, eps=None):
|
||||||
"""Computes the Kullback-Leibler divergence between the two prevalence distributions.
|
"""Computes the Kullback-Leibler divergence between the two prevalence distributions.
|
||||||
Kullback-Leibler divergence between two prevalence distributions :math:`p` and :math:`\\hat{p}` is computed as
|
Kullback-Leibler divergence between two prevalence distributions :math:`p` and :math:`\\hat{p}`
|
||||||
:math:`KLD(p,\\hat{p})=D_{KL}(p||\\hat{p})=\\sum_{y\\in \\mathcal{Y}} p(y)\\log\\frac{p(y)}{\\hat{p}(y)}`, where
|
is computed as
|
||||||
:math:`\\mathcal{Y}` are the classes of interest.
|
:math:`KLD(p,\\hat{p})=D_{KL}(p||\\hat{p})=
|
||||||
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
\\sum_{y\\in \\mathcal{Y}} p(y)\\log\\frac{p(y)}{\\hat{p}(y)}`,
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
|
||||||
:param prevs_hat: array-like of shape `(n_classes,)` with the predicted prevalence values
|
|
||||||
:param eps: smoothing factor. KLD is not defined in cases in which the distributions contain zeros; `eps`
|
|
||||||
is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size. If `eps=None`, the sample size
|
|
||||||
will be taken from the environment variable `SAMPLE_SIZE` (which has thus to be set beforehand).
|
|
||||||
:return: Kullback-Leibler divergence between the two distributions
|
|
||||||
"""
|
|
||||||
eps = __check_eps(eps)
|
|
||||||
sp = p+eps
|
|
||||||
sp_hat = p_hat + eps
|
|
||||||
return (sp*np.log(sp/sp_hat)).sum(axis=-1)
|
|
||||||
|
|
||||||
|
|
||||||
def mnkld(prevs, prevs_hat, eps=None):
|
|
||||||
"""Computes the mean Normalized Kullback-Leibler divergence (see :meth:`quapy.error.nkld`) across the sample pairs.
|
|
||||||
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true prevalence values
|
|
||||||
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted prevalence values
|
|
||||||
:param eps: smoothing factor. NKLD is not defined in cases in which the distributions contain zeros; `eps`
|
|
||||||
is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size. If `eps=None`, the sample size
|
|
||||||
will be taken from the environment variable `SAMPLE_SIZE` (which has thus to be set beforehand).
|
|
||||||
:return: mean Normalized Kullback-Leibler distribution
|
|
||||||
"""
|
|
||||||
return nkld(prevs, prevs_hat, eps).mean()
|
|
||||||
|
|
||||||
|
|
||||||
def nkld(p, p_hat, eps=None):
|
|
||||||
"""Computes the Normalized Kullback-Leibler divergence between the two prevalence distributions.
|
|
||||||
Normalized Kullback-Leibler divergence between two prevalence distributions :math:`p` and :math:`\\hat{p}`
|
|
||||||
is computed as :math:`NKLD(p,\\hat{p}) = 2\\frac{e^{KLD(p,\\hat{p})}}{e^{KLD(p,\\hat{p})}+1}-1`, where
|
|
||||||
:math:`\\mathcal{Y}` are the classes of interest.
|
|
||||||
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
|
||||||
:param prevs_hat: array-like of shape `(n_classes,)` with the predicted prevalence values
|
|
||||||
:param eps: smoothing factor. NKLD is not defined in cases in which the distributions contain zeros; `eps`
|
|
||||||
is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size. If `eps=None`, the sample size
|
|
||||||
will be taken from the environment variable `SAMPLE_SIZE` (which has thus to be set beforehand).
|
|
||||||
:return: Normalized Kullback-Leibler divergence between the two distributions
|
|
||||||
"""
|
|
||||||
ekld = np.exp(kld(p, p_hat, eps))
|
|
||||||
return 2. * ekld / (1 + ekld) - 1.
|
|
||||||
|
|
||||||
|
|
||||||
def mrae(p, p_hat, eps=None):
|
|
||||||
"""Computes the mean relative absolute error (see :meth:`quapy.error.rae`) across the sample pairs.
|
|
||||||
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true prevalence values
|
|
||||||
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted prevalence values
|
|
||||||
:param eps: smoothing factor. `mrae` is not defined in cases in which the true distribution contains zeros; `eps`
|
|
||||||
is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size. If `eps=None`, the sample size
|
|
||||||
will be taken from the environment variable `SAMPLE_SIZE` (which has thus to be set beforehand).
|
|
||||||
:return: mean relative absolute error
|
|
||||||
"""
|
|
||||||
return rae(p, p_hat, eps).mean()
|
|
||||||
|
|
||||||
|
|
||||||
def rae(p, p_hat, eps=None):
|
|
||||||
"""Computes the absolute relative error between the two prevalence vectors.
|
|
||||||
Relative absolute error between two prevalence vectors :math:`p` and :math:`\\hat{p}` is computed as
|
|
||||||
:math:`RAE(p,\\hat{p})=\\frac{1}{|\\mathcal{Y}|}\\sum_{y\in \mathcal{Y}}\\frac{|\\hat{p}(y)-p(y)|}{p(y)}`,
|
|
||||||
where :math:`\\mathcal{Y}` are the classes of interest.
|
where :math:`\\mathcal{Y}` are the classes of interest.
|
||||||
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
||||||
:param prevs_hat: array-like of shape `(n_classes,)` with the predicted prevalence values
|
:param prevs_hat: array-like of shape `(n_classes,)` with the predicted prevalence values
|
||||||
:param eps: smoothing factor. `rae` is not defined in cases in which the true distribution contains zeros; `eps`
|
:param eps: smoothing factor. KLD is not defined in cases in which the distributions contain
|
||||||
is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size. If `eps=None`, the sample size
|
zeros; `eps` is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size.
|
||||||
will be taken from the environment variable `SAMPLE_SIZE` (which has thus to be set beforehand).
|
If `eps=None`, the sample size will be taken from the environment variable `SAMPLE_SIZE`
|
||||||
|
(which has thus to be set beforehand).
|
||||||
|
:return: Kullback-Leibler divergence between the two distributions
|
||||||
|
"""
|
||||||
|
eps = __check_eps(eps)
|
||||||
|
smooth_prevs = prevs + eps
|
||||||
|
smooth_prevs_hat = prevs_hat + eps
|
||||||
|
return (smooth_prevs*np.log(smooth_prevs/smooth_prevs_hat)).sum(axis=-1)
|
||||||
|
|
||||||
|
|
||||||
|
def mnkld(prevs, prevs_hat, eps=None):
|
||||||
|
"""Computes the mean Normalized Kullback-Leibler divergence (see :meth:`quapy.error.nkld`)
|
||||||
|
across the sample pairs. The distributions are smoothed using the `eps` factor
|
||||||
|
(see :meth:`quapy.error.smooth`).
|
||||||
|
|
||||||
|
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true prevalence values
|
||||||
|
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted
|
||||||
|
prevalence values
|
||||||
|
:param eps: smoothing factor. NKLD is not defined in cases in which the distributions contain
|
||||||
|
zeros; `eps` is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample size.
|
||||||
|
If `eps=None`, the sample size will be taken from the environment variable `SAMPLE_SIZE`
|
||||||
|
(which has thus to be set beforehand).
|
||||||
|
:return: mean Normalized Kullback-Leibler distribution
|
||||||
|
"""
|
||||||
|
return nkld(prevs, prevs_hat, eps).mean()
|
||||||
|
|
||||||
|
|
||||||
|
def nkld(prevs, prevs_hat, eps=None):
|
||||||
|
"""Computes the Normalized Kullback-Leibler divergence between the two prevalence distributions.
|
||||||
|
Normalized Kullback-Leibler divergence between two prevalence distributions :math:`p` and
|
||||||
|
:math:`\\hat{p}` is computed as
|
||||||
|
math:`NKLD(p,\\hat{p}) = 2\\frac{e^{KLD(p,\\hat{p})}}{e^{KLD(p,\\hat{p})}+1}-1`,
|
||||||
|
where
|
||||||
|
:math:`\\mathcal{Y}` are the classes of interest.
|
||||||
|
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
||||||
|
|
||||||
|
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
||||||
|
:param prevs_hat: array-like of shape `(n_classes,)` with the predicted prevalence values
|
||||||
|
:param eps: smoothing factor. NKLD is not defined in cases in which the distributions
|
||||||
|
contain zeros; `eps` is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the sample
|
||||||
|
size. If `eps=None`, the sample size will be taken from the environment variable
|
||||||
|
`SAMPLE_SIZE` (which has thus to be set beforehand).
|
||||||
|
:return: Normalized Kullback-Leibler divergence between the two distributions
|
||||||
|
"""
|
||||||
|
ekld = np.exp(kld(prevs, prevs_hat, eps))
|
||||||
|
return 2. * ekld / (1 + ekld) - 1.
|
||||||
|
|
||||||
|
|
||||||
|
def mrae(prevs, prevs_hat, eps=None):
|
||||||
|
"""Computes the mean relative absolute error (see :meth:`quapy.error.rae`) across
|
||||||
|
the sample pairs. The distributions are smoothed using the `eps` factor (see
|
||||||
|
:meth:`quapy.error.smooth`).
|
||||||
|
|
||||||
|
:param prevs: array-like of shape `(n_samples, n_classes,)` with the true
|
||||||
|
prevalence values
|
||||||
|
:param prevs_hat: array-like of shape `(n_samples, n_classes,)` with the predicted
|
||||||
|
prevalence values
|
||||||
|
:param eps: smoothing factor. `mrae` is not defined in cases in which the true
|
||||||
|
distribution contains zeros; `eps` is typically set to be :math:`\\frac{1}{2T}`,
|
||||||
|
with :math:`T` the sample size. If `eps=None`, the sample size will be taken from
|
||||||
|
the environment variable `SAMPLE_SIZE` (which has thus to be set beforehand).
|
||||||
|
:return: mean relative absolute error
|
||||||
|
"""
|
||||||
|
return rae(prevs, prevs_hat, eps).mean()
|
||||||
|
|
||||||
|
|
||||||
|
def rae(prevs, prevs_hat, eps=None):
|
||||||
|
"""Computes the absolute relative error between the two prevalence vectors.
|
||||||
|
Relative absolute error between two prevalence vectors :math:`p` and :math:`\\hat{p}`
|
||||||
|
is computed as
|
||||||
|
:math:`RAE(p,\\hat{p})=
|
||||||
|
\\frac{1}{|\\mathcal{Y}|}\\sum_{y\\in \\mathcal{Y}}\\frac{|\\hat{p}(y)-p(y)|}{p(y)}`,
|
||||||
|
where :math:`\\mathcal{Y}` are the classes of interest.
|
||||||
|
The distributions are smoothed using the `eps` factor (see :meth:`quapy.error.smooth`).
|
||||||
|
|
||||||
|
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
||||||
|
:param prevs_hat: array-like of shape `(n_classes,)` with the predicted prevalence values
|
||||||
|
:param eps: smoothing factor. `rae` is not defined in cases in which the true distribution
|
||||||
|
contains zeros; `eps` is typically set to be :math:`\\frac{1}{2T}`, with :math:`T` the
|
||||||
|
sample size. If `eps=None`, the sample size will be taken from the environment variable
|
||||||
|
`SAMPLE_SIZE` (which has thus to be set beforehand).
|
||||||
:return: relative absolute error
|
:return: relative absolute error
|
||||||
"""
|
"""
|
||||||
eps = __check_eps(eps)
|
eps = __check_eps(eps)
|
||||||
p = smooth(p, eps)
|
prevs = smooth(prevs, eps)
|
||||||
p_hat = smooth(p_hat, eps)
|
prevs_hat = smooth(prevs_hat, eps)
|
||||||
return (abs(p-p_hat)/p).mean(axis=-1)
|
return (abs(prevs - prevs_hat) / prevs).mean(axis=-1)
|
||||||
|
|
||||||
|
|
||||||
def smooth(prevs, eps):
|
def smooth(prevs, eps):
|
||||||
""" Smooths a prevalence distribution with :math:`\epsilon` (`eps`) as:
|
""" Smooths a prevalence distribution with :math:`\\epsilon` (`eps`) as:
|
||||||
:math:`\\underline{p}(y)=\\frac{\\epsilon+p(y)}{\\epsilon|\\mathcal{Y}|+\\displaystyle\\sum_{y\\in \\mathcal{Y}}p(y)}`
|
:math:`\\underline{p}(y)=\\frac{\\epsilon+p(y)}{\\epsilon|\\mathcal{Y}|+
|
||||||
|
\\displaystyle\\sum_{y\\in \\mathcal{Y}}p(y)}`
|
||||||
|
|
||||||
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
:param prevs: array-like of shape `(n_classes,)` with the true prevalence values
|
||||||
:param eps: smoothing factor
|
:param eps: smoothing factor
|
||||||
|
@ -200,12 +231,10 @@ def smooth(prevs, eps):
|
||||||
|
|
||||||
def __check_eps(eps=None):
|
def __check_eps(eps=None):
|
||||||
if eps is None:
|
if eps is None:
|
||||||
import quapy as qp
|
|
||||||
sample_size = qp.environ['SAMPLE_SIZE']
|
sample_size = qp.environ['SAMPLE_SIZE']
|
||||||
if sample_size is None:
|
if sample_size is None:
|
||||||
raise ValueError('eps was not defined, and qp.environ["SAMPLE_SIZE"] was not set')
|
raise ValueError('eps was not defined, and qp.environ["SAMPLE_SIZE"] was not set')
|
||||||
else:
|
eps = 1. / (2. * sample_size)
|
||||||
eps = 1. / (2. * sample_size)
|
|
||||||
return eps
|
return eps
|
||||||
|
|
||||||
|
|
||||||
|
@ -217,7 +246,8 @@ CLASSIFICATION_ERROR_NAMES = {func.__name__ for func in CLASSIFICATION_ERROR}
|
||||||
QUANTIFICATION_ERROR_NAMES = {func.__name__ for func in QUANTIFICATION_ERROR}
|
QUANTIFICATION_ERROR_NAMES = {func.__name__ for func in QUANTIFICATION_ERROR}
|
||||||
QUANTIFICATION_ERROR_SINGLE_NAMES = {func.__name__ for func in QUANTIFICATION_ERROR_SINGLE}
|
QUANTIFICATION_ERROR_SINGLE_NAMES = {func.__name__ for func in QUANTIFICATION_ERROR_SINGLE}
|
||||||
QUANTIFICATION_ERROR_SMOOTH_NAMES = {func.__name__ for func in QUANTIFICATION_ERROR_SMOOTH}
|
QUANTIFICATION_ERROR_SMOOTH_NAMES = {func.__name__ for func in QUANTIFICATION_ERROR_SMOOTH}
|
||||||
ERROR_NAMES = CLASSIFICATION_ERROR_NAMES | QUANTIFICATION_ERROR_NAMES | QUANTIFICATION_ERROR_SINGLE_NAMES
|
ERROR_NAMES = \
|
||||||
|
CLASSIFICATION_ERROR_NAMES | QUANTIFICATION_ERROR_NAMES | QUANTIFICATION_ERROR_SINGLE_NAMES
|
||||||
|
|
||||||
f1_error = f1e
|
f1_error = f1e
|
||||||
acc_error = acce
|
acc_error = acce
|
||||||
|
@ -225,4 +255,3 @@ mean_absolute_error = mae
|
||||||
absolute_error = ae
|
absolute_error = ae
|
||||||
mean_relative_absolute_error = mrae
|
mean_relative_absolute_error = mrae
|
||||||
relative_absolute_error = rae
|
relative_absolute_error = rae
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue