<spanid="quapy-classification-methods-module"></span><h2>quapy.classification.methods module<aclass="headerlink"href="#module-quapy.classification.methods"title="Permalink to this headline">¶</a></h2>
<emclass="property"><spanclass="pre">class</span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.classification.methods.</span></span><spanclass="sig-name descname"><spanclass="pre">LowRankLogisticRegression</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">n_components</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">100</span></span></em>, <emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">kwargs</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.methods.LowRankLogisticRegression"title="Permalink to this definition">¶</a></dt>
<p>An example of a classification method (i.e., an object that implements <cite>fit</cite>, <cite>predict</cite>, and <cite>predict_proba</cite>)
that also generates embedded inputs (i.e., that implements <cite>transform</cite>), as those required for
<codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.method.neural.QuaNet</span></code>. This is a mock method to allow for easily instantiating
<codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.method.neural.QuaNet</span></code> on array-like real-valued instances.
The transformation consists of applying <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">sklearn.decomposition.TruncatedSVD</span></code>
while classification is performed using <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">sklearn.linear_model.LogisticRegression</span></code> on the low-rank space.</p>
<spanclass="sig-name descname"><spanclass="pre">fit</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">X</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">y</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.methods.LowRankLogisticRegression.fit"title="Permalink to this definition">¶</a></dt>
<dd><p>Fit the model according to the given training data. The fit consists of
<spanclass="sig-name descname"><spanclass="pre">get_params</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.methods.LowRankLogisticRegression.get_params"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">predict</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">X</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.methods.LowRankLogisticRegression.predict"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">predict_proba</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">X</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.methods.LowRankLogisticRegression.predict_proba"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">set_params</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">params</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.methods.LowRankLogisticRegression.set_params"title="Permalink to this definition">¶</a></dt>
<dd><p>Set the parameters of this estimator.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>parameters</strong>– a <cite>**kwargs</cite> dictionary with the estimator parameters for
<spanclass="sig-name descname"><spanclass="pre">transform</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">X</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.methods.LowRankLogisticRegression.transform"title="Permalink to this definition">¶</a></dt>
<spanid="quapy-classification-neural-module"></span><h2>quapy.classification.neural module<aclass="headerlink"href="#module-quapy.classification.neural"title="Permalink to this headline">¶</a></h2>
<p>An implementation of <aclass="reference internal"href="#quapy.classification.neural.TextClassifierNet"title="quapy.classification.neural.TextClassifierNet"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.classification.neural.TextClassifierNet</span></code></a> based on
Convolutional Neural Networks.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>vocabulary_size</strong>– the size of the vocabulary</p></li>
<li><p><strong>n_classes</strong>– number of target classes</p></li>
<li><p><strong>embedding_size</strong>– the dimensionality of the word embeddings space (default 100)</p></li>
<li><p><strong>hidden_size</strong>– the dimensionality of the hidden space (default 256)</p></li>
<li><p><strong>repr_size</strong>– the dimensionality of the document embeddings space (default 100)</p></li>
<li><p><strong>kernel_heights</strong>– list of kernel lengths (default [3,5,7]), i.e., the number of
consecutive tokens that each kernel covers</p></li>
<spanclass="sig-name descname"><spanclass="pre">document_embedding</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">input</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.CNNnet.document_embedding"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">get_params</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.CNNnet.get_params"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span></em><spanclass="sig-name descname"><spanclass="pre">vocabulary_size</span></span><aclass="headerlink"href="#quapy.classification.neural.CNNnet.vocabulary_size"title="Permalink to this definition">¶</a></dt>
<p>An implementation of <aclass="reference internal"href="#quapy.classification.neural.TextClassifierNet"title="quapy.classification.neural.TextClassifierNet"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">quapy.classification.neural.TextClassifierNet</span></code></a> based on
Long Short Term Memory networks.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>vocabulary_size</strong>– the size of the vocabulary</p></li>
<li><p><strong>n_classes</strong>– number of target classes</p></li>
<li><p><strong>embedding_size</strong>– the dimensionality of the word embeddings space (default 100)</p></li>
<li><p><strong>hidden_size</strong>– the dimensionality of the hidden space (default 256)</p></li>
<li><p><strong>repr_size</strong>– the dimensionality of the document embeddings space (default 100)</p></li>
<li><p><strong>lstm_class_nlayers</strong>– number of LSTM layers (default 1)</p></li>
<li><p><strong>drop_p</strong>– drop probability for dropout (default 0.5)</p></li>
<spanclass="sig-name descname"><spanclass="pre">document_embedding</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">x</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.LSTMnet.document_embedding"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">get_params</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.LSTMnet.get_params"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span></em><spanclass="sig-name descname"><spanclass="pre">vocabulary_size</span></span><aclass="headerlink"href="#quapy.classification.neural.LSTMnet.vocabulary_size"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span></em><spanclass="sig-name descname"><spanclass="pre">device</span></span><aclass="headerlink"href="#quapy.classification.neural.NeuralClassifierTrainer.device"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">fit</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">instances</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">labels</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">val_split</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">0.3</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.NeuralClassifierTrainer.fit"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">get_params</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.NeuralClassifierTrainer.get_params"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">predict</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">instances</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.NeuralClassifierTrainer.predict"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">predict_proba</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">instances</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.NeuralClassifierTrainer.predict_proba"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">reset_net_params</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">vocab_size</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">n_classes</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.NeuralClassifierTrainer.reset_net_params"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">set_params</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">params</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.NeuralClassifierTrainer.set_params"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">transform</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">instances</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.NeuralClassifierTrainer.transform"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">class</span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.classification.neural.</span></span><spanclass="sig-name descname"><spanclass="pre">TextClassifierNet</span></span><aclass="headerlink"href="#quapy.classification.neural.TextClassifierNet"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">dimensions</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.TextClassifierNet.dimensions"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">abstract</span></em><spanclass="sig-name descname"><spanclass="pre">document_embedding</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">x</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.TextClassifierNet.document_embedding"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">forward</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">x</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.TextClassifierNet.forward"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">abstract</span></em><spanclass="sig-name descname"><spanclass="pre">get_params</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.TextClassifierNet.get_params"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">predict_proba</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">x</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.TextClassifierNet.predict_proba"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">property</span></em><spanclass="sig-name descname"><spanclass="pre">vocabulary_size</span></span><aclass="headerlink"href="#quapy.classification.neural.TextClassifierNet.vocabulary_size"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">xavier_uniform</span></span><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.TextClassifierNet.xavier_uniform"title="Permalink to this definition">¶</a></dt>
<emclass="property"><spanclass="pre">class</span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.classification.neural.</span></span><spanclass="sig-name descname"><spanclass="pre">TorchDataset</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">instances</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">labels</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.TorchDataset"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">asDataloader</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">batch_size</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">shuffle</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">pad_length</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">device</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.neural.TorchDataset.asDataloader"title="Permalink to this definition">¶</a></dt>
<spanid="quapy-classification-svmperf-module"></span><h2>quapy.classification.svmperf module<aclass="headerlink"href="#module-quapy.classification.svmperf"title="Permalink to this headline">¶</a></h2>
<emclass="property"><spanclass="pre">class</span></em><spanclass="sig-prename descclassname"><spanclass="pre">quapy.classification.svmperf.</span></span><spanclass="sig-name descname"><spanclass="pre">SVMperf</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">svmperf_base</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">C</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">0.01</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">verbose</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">False</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">loss</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">'01'</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.svmperf.SVMperf"title="Permalink to this definition">¶</a></dt>
<p>A wrapper for the <aclass="reference external"href="https://www.cs.cornell.edu/people/tj/svm_light/svm_perf.html">SVM-perf package</a> by Thorsten Joachims.
When using losses for quantification, the source code has to be patched. See
the <aclass="reference external"href="https://hlt-isti.github.io/QuaPy/build/html/Installation.html#svm-perf-with-quantification-oriented-losses">installation documentation</a>
for further details.</p>
<p>References:</p>
<blockquote>
<div><ulclass="simple">
<li><p><aclass="reference external"href="https://dl.acm.org/doi/abs/10.1145/2700406?casa_token=8D2fHsGCVn0AAAAA:ZfThYOvrzWxMGfZYlQW_y8Cagg-o_l6X_PcF09mdETQ4Tu7jK98mxFbGSXp9ZSO14JkUIYuDGFG0">Esuli et al.2015</a></p></li>
<li><p><aclass="reference external"href="https://www.sciencedirect.com/science/article/abs/pii/S003132031400291X">Barranquero et al.2015</a></p></li>
</ul>
</div></blockquote>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>svmperf_base</strong>– path to directory containing the binary files <cite>svm_perf_learn</cite> and <cite>svm_perf_classify</cite></p></li>
<li><p><strong>C</strong>– trade-off between training error and margin (default 0.01)</p></li>
<li><p><strong>verbose</strong>– set to True to print svm-perf std outputs</p></li>
<li><p><strong>loss</strong>– the loss to optimize for. Available losses are “01”, “f1”, “kld”, “nkld”, “q”, “qacc”, “qf1”, “qgm”, “mae”, “mrae”.</p></li>
<spanclass="sig-name descname"><spanclass="pre">decision_function</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">X</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">y</span></span><spanclass="o"><spanclass="pre">=</span></span><spanclass="default_value"><spanclass="pre">None</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.svmperf.SVMperf.decision_function"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">fit</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">X</span></span></em>, <emclass="sig-param"><spanclass="n"><spanclass="pre">y</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.svmperf.SVMperf.fit"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">predict</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n"><spanclass="pre">X</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.svmperf.SVMperf.predict"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">set_params</span></span><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o"><spanclass="pre">**</span></span><spanclass="n"><spanclass="pre">parameters</span></span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#quapy.classification.svmperf.SVMperf.set_params"title="Permalink to this definition">¶</a></dt>
<spanclass="sig-name descname"><spanclass="pre">valid_losses</span></span><emclass="property"><spanclass="pre">=</span><spanclass="pre">{'01':</span><spanclass="pre">0,</span><spanclass="pre">'f1':</span><spanclass="pre">1,</span><spanclass="pre">'kld':</span><spanclass="pre">12,</span><spanclass="pre">'mae':</span><spanclass="pre">26,</span><spanclass="pre">'mrae':</span><spanclass="pre">27,</span><spanclass="pre">'nkld':</span><spanclass="pre">13,</span><spanclass="pre">'q':</span><spanclass="pre">22,</span><spanclass="pre">'qacc':</span><spanclass="pre">23,</span><spanclass="pre">'qf1':</span><spanclass="pre">24,</span><spanclass="pre">'qgm':</span><spanclass="pre">25}</span></em><aclass="headerlink"href="#quapy.classification.svmperf.SVMperf.valid_losses"title="Permalink to this definition">¶</a></dt>
<spanid="module-contents"></span><h2>Module contents<aclass="headerlink"href="#module-quapy.classification"title="Permalink to this headline">¶</a></h2>