Metadata-Version: 2.1
Name: lazy-text-classifiers
Version: 0.1.0
Summary: Build and test a variety of text multi-class classification models.
Author-email: Eva Maxfield Brown <evamaxfieldbrown@gmail.com>
License: MIT License
Project-URL: Homepage, https://github.com/evamaxfield/lazy-text-classifiers
Project-URL: Bug Tracker, https://github.com/evamaxfield/lazy-text-classifiers/issues
Project-URL: Documentation, https://evamaxfield.github.io/lazy-text-classifiers
Project-URL: User Support, https://github.com/evamaxfield/lazy-text-classifiers/issues
Classifier: Development Status :: 4 - Beta
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: datasets (~=2.0)
Requires-Dist: embetter (~=0.3)
Requires-Dist: numpy
Requires-Dist: pandas (~=1.0)
Requires-Dist: scikit-learn (~=1.2)
Requires-Dist: sentence-transformers
Requires-Dist: setfit (~=0.5)
Requires-Dist: torch
Requires-Dist: transformers (~=4.0)
Provides-Extra: dev
Requires-Dist: ipython (>=8.4.0) ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: m2r2 (>=0.2.7) ; extra == 'docs'
Requires-Dist: Sphinx (>=4.0.0) ; extra == 'docs'
Requires-Dist: furo (>=2022.4.7) ; extra == 'docs'
Requires-Dist: numpydoc ; extra == 'docs'
Requires-Dist: sphinx-copybutton ; extra == 'docs'
Requires-Dist: docutils (<0.19,>=0.18) ; extra == 'docs'
Provides-Extra: lint
Requires-Dist: black (>=22.3.0) ; extra == 'lint'
Requires-Dist: check-manifest (>=0.48) ; extra == 'lint'
Requires-Dist: ruff (>=0.0.216) ; extra == 'lint'
Requires-Dist: mypy (>=0.790) ; extra == 'lint'
Requires-Dist: pre-commit (>=2.20.0) ; extra == 'lint'
Provides-Extra: test
Requires-Dist: coverage (>=5.1) ; extra == 'test'
Requires-Dist: pytest (>=5.4.3) ; extra == 'test'
Requires-Dist: pytest-cov (>=2.9.0) ; extra == 'test'
Requires-Dist: pytest-raises (>=0.11) ; extra == 'test'

# lazy-text-classifiers

[![Build Status](https://github.com/evamaxfield/lazy-text-classifiers/workflows/CI/badge.svg)](https://github.com/evamaxfield/lazy-text-classifiers/actions)
[![Documentation](https://github.com/evamaxfield/lazy-text-classifiers/workflows/Documentation/badge.svg)](https://evamaxfield.github.io/lazy-text-classifiers)

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

---

## Installation

**Stable Release:** `pip install lazy-text-classifiers`<br>
**Development Head:** `pip install git+https://github.com/evamaxfield/lazy-text-classifiers.git`

## Quickstart

```python
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](https://evamaxfield.github.io/lazy-text-classifiers).

## Acknowledgements

This package was heavily inspired by [lazypredict](https://github.com/shankarpandala/lazypredict).

## Development

See [CONTRIBUTING.md](CONTRIBUTING.md) for information related to developing the code.

**MIT License**
