Hybrid models

Semi-supervised model

class src.models.hybrid.semi_supervised.HybridModel(config: Config, logger: Logger, taxonomy: Taxonomy, supervised_model: Model, unsupervised_model: Model)[source]

Bases: Model

The HybridModel class implements a semi-supervised approach.

It starts with a base model and uses one of the unsupervised flavours for the rest of the predictions in the tree.

_prep_labels(taxonomy: Taxonomy) None[source]

The function that prepares the labels, this converts them to the required format for further processing with a model. :param taxonomy: Taxonomy object where we will use the labels from :return:

classify(text: str, multi_label: bool, **kwargs) dict[str, float][source]

Abstract function that executes the text classificatoin

Parameters:
  • text – the text to classify

  • multi_label – boolean to identify if it is a multilabel problem

  • kwargs – potential extra vars

Returns:

the results

Semi-supervised selective model

class src.models.hybrid.semi_supervised_selective.SelectiveHybridModel(config: Config, logger: Logger, taxonomy: Taxonomy, supervised_model: Model, unsupervised_model: Model)[source]

Bases: Model

Selective hybrid model is similar to the regular hybrid model, the only difference is that it only processes outputs of sub-nodes in the tree if they exceed a certain threshold

_prep_labels(taxonomy: Taxonomy) None[source]

The function that prepares the labels, this converts them to the required format for further processing with a model. :param taxonomy: Taxonomy object where we will use the labels from :return:

classify(text: str, multi_label: bool, **kwargs) dict[str, float][source]

Abstract function that executes the text classificatoin

Parameters:
  • text – the text to classify

  • multi_label – boolean to identify if it is a multilabel problem

  • kwargs – potential extra vars

Returns:

the results