lazy_text_classifiers package#

Subpackages#

Submodules#

lazy_text_classifiers.constants module#

class lazy_text_classifiers.constants.ModelNames[source]#

Bases: object

setfit_transformer = 'setfit-transformer'#
tfidf_logit = 'tfidf-logit'#

lazy_text_classifiers.logging_utils module#

lazy_text_classifiers.logging_utils.set_global_logging_level(level: int = 40, prefices: list[str] | None = None) None[source]#

Override logging levels of different modules based on their name as a prefix. It needs to be invoked after the modules have been loaded so that their loggers have been initialized.

Parameters:
level: int

Desired level. e.g. logging.INFO. Default is logging.ERROR

prefices: list[str] | None

One or more string prefices to match (e.g. [“transformers”, “torch”]) Default of None will match all loggers. The match is a case-sensitive module_name.startswith(prefix)

Notes

Credit: https://github.com/huggingface/transformers/issues/3050#issuecomment-682167272

lazy_text_classifiers.model_selection module#

class lazy_text_classifiers.model_selection.LazyTextClassifiers(verbose: int = 1, ignore_warnings: bool = True, random_state: int | None = None)[source]#

Bases: object

Class for managing fitting all classifiers.

Parameters:
verbose: int

Logging verbosity level. Levels:

0 - no logging; 1 - log basic progress; 2 - log everything;

Default: 1 (log basic progress)

ignore_warnings: bool

Should all warnings be ignores.

random_state: int | None

A seed to initialize random state. Default: None (no pre-set random seed)

fit(x_train: Collection[str], x_test: Collection[str], y_train: Collection[str], y_test: Collection[str], model_kwargs: dict[str, Any] | None = None) DataFrame[source]#

Fit all models with the provided data.

Parameters:
x_train: Collection[str]

The training data, an iterable object where each item is a string.

x_test: Collection[str]

The testing data, an iterable object where each item is a string.

y_train: Collection[str]

The training labels, an iterable object where each item is a class.

y_test: Collection[str]

The testing labels, an iterable object where each item is a class.

model_kwargs: dict[str, Any] | None

Any specific model kwargs to pass through. Default None (use default parameters and settings for all models)

Returns:
pd.DataFrame

The results and metrics returned from fitting all models.

Module contents#

Top-level package for lazy_text_classifiers.