Skip to main content

lazy-text-classifiers

Build Status Documentation

Build and test a variety of text multi-class classification models.


Installation

Stable Release: pip install lazy-text-classifiers
Development Head: pip install git+https://github.com/evamaxfield/lazy-text-classifiers.git

Quickstart

from lazy_text_classifiers import LazyTextClassifiers
from sklearn.datasets import fetch_20newsgroups
from sklearn.model_selection import train_test_split

# Example data from sklearn
# `x` should be an iterable of strings
# `y` should be an iterable of string labels
data = fetch_20newsgroups(subset="all", remove=("header", "footers", "quotes"))
x = data.data[:1000]
y = data.target[:1000]
y = [data.target_names[id_] for id_ in y]

# Split the data into train and test
x_train, x_test, y_train, y_test = train_test_split(
    x,
    y,
    test_size=0.4,
    random_state=12,
)

# Init and fit all models
ltc = LazyTextClassifiers(random_state=12)
results = ltc.fit(x_train, x_test, y_train, y_test)

# Results is a dataframe
# | model                  |   accuracy |   balanced_accuracy |   precision |   recall |       f1 |    time |
# |:-----------------------|-----------:|--------------------:|------------:|---------:|---------:|--------:|
# | semantic-logit         |    0.73    |            0.725162 |    0.734887 |  0.73    | 0.728247 |  13.742 |
# | tfidf-logit            |    0.70625 |            0.700126 |    0.709781 |  0.70625 | 0.702073 | 187.217 |
# | fine-tuned-transformer |    0.11125 |            0.1118   |    0.10998  |  0.11125 | 0.109288 | 220.105 |

# Get a specific model
semantic_logit = ltc.fit_models["semantic-logit"]
# either an scikit-learn Pipeline or a custom Transformer wrapper class

# All models have a `save` function which will store into the normal format
# * pickle for scikit-learn pipelines
# * torch model directory for Transformers

Documentation

For full package documentation please visit evamaxfield.github.io/lazy-text-classifiers.

Acknowledgements

This package was heavily inspired by lazypredict.

Development

See CONTRIBUTING.md for information related to developing the code.

MIT License

Metadata

Release files for lazy-text-classifiers 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lazy-text-classifiers 0.1.0
File Size Uploaded
lazy-text-classifiers-0.1.0.tar.gz 21.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lazy-text-classifiers 0.1.0
File Interpreter ABI Platform
lazy_text_classifiers-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.3 kB

Release files / lazy-text-classifiers-0.1.0.tar.gz

Download URL lazy-text-classifiers-0.1.0.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
95388c7b7d9b6dba55939ce31d2e74678b3bc5fab990ff78c1c5639bb520a495
BLAKE2b-256 checksum
How to use checksums
3474ae5e5bc3776e635ff71a1ccafbcf713ebbba6d10ab0f13c92f00dfdae085
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Release files / lazy_text_classifiers-0.1.0-py3-none-any.whl

Download URL lazy_text_classifiers-0.1.0-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afc2327105e2a008bc0552cab4dd3630817d3d19721916364f33c02e4b4a5b5e
BLAKE2b-256 checksum
How to use checksums
cfa4f5483621060970cf0ab50cf2166a4b0f51b098dc716667a0745adaffb8a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page