Skip to main content

A Python package for text classification using transformer models.

Project description

TextPredict

python PyPI - Version Code style: black Ruff security: bandit Downloads

TextPredict Logo

Advanced Text Classification with Transformer Models

TextPredict is a powerful Python package designed for text classification tasks leveraging advanced transformer models. It supports a variety of tasks including sentiment analysis, emotion detection, and zero-shot classification, making it an essential tool for developers and data scientists working in natural language processing (NLP), machine learning (ML), and artificial intelligence (AI).

Features

  • Sentiment Analysis: Classify text based on sentiment with high accuracy.
  • Emotion Detection: Detect emotions in text effortlessly.
  • Zero-Shot Classification: Classify text into unseen categories without any additional training.
  • Fine-Tuning: Easily fine-tune models to improve performance on specific datasets.
  • Model Evaluation: Evaluate model performance with robust metrics.
  • Distributed Training: Support for distributed training to leverage multiple GPUs.

Installation

pip install textpredict

Usage

Sentiment Analysis

from textpredict import TextPredict

tp = TextPredict()
result = tp.analyse("I love using this package!", task="sentiment")
print(result)

Emotion Detection

result = tp.analyse("I am excited about this!", task="emotion")
print(result)

Zero-Shot Classification

result = tp.analyse(
    "This package is great for zero-shot learning.",
    task="zeroshot",
    class_list=["positive", "negative", "neutral"],
)
print(result)

Fine-Tuning Models

from datasets import load_dataset

# Load dataset
dataset = load_dataset("imdb")

# Fine-tune model
tp.tune_model(
    task="sentiment",
    training_data=dataset["train"],
    eval_data=dataset["test"],
    num_train_epochs=1,
    batch_size=8,
    learning_rate=2e-5,
    early_stopping_patience=3,
)

Evaluating Models

metrics = tp.evaluate_model(task="sentiment", eval_data=dataset["test"])
print("Evaluation metrics:", metrics)

Saving and Loading Models

tp.save_model(task="sentiment", output_dir="./fine_tuned_sentiment_model")
tp.load_model(task="sentiment", model_dir="./fine_tuned_sentiment_model")
result = tp.analyse("I love using this package after fine-tuning!", task="sentiment")
print(result)

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textpredict-0.1.2.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

textpredict-0.1.2-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file textpredict-0.1.2.tar.gz.

File metadata

  • Download URL: textpredict-0.1.2.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-41-generic

File hashes

Hashes for textpredict-0.1.2.tar.gz
Algorithm Hash digest
SHA256 893a0c238d9b0af46ffd22e3e043346ea9e35c4015efa734053551e95644f868
MD5 0453d7148500fc9ddd1dab477666072c
BLAKE2b-256 f785fd1c8d83c827a43fad16322a80de232bd35b28c190524c1b368f6f293e5b

See more details on using hashes here.

File details

Details for the file textpredict-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: textpredict-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-41-generic

File hashes

Hashes for textpredict-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9cbc9cd94566d702f61d15edaeb44523ddf8576cc3d9509e70ee3b5da0e957ea
MD5 edf0e74b9bc7f8b181ba649a5ac26412
BLAKE2b-256 21e9a8b65d418776fdf84488c716ed02dcea20c9b079a93da6eaca5ea3bb5a86

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page