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

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.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

textpredict-0.1.1-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: textpredict-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 9ec6b153b376c89d5ba29db4ba228bd229279af8df4c3a0ba37214f205607a9b
MD5 226c2ec42f1a11c5fab160459720defa
BLAKE2b-256 7db75ef8090b29ffa1f28432e5008e00eda66248ff13bacd35c4c06214dcc3b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: textpredict-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3797814f85169679c7a025d46020b4c5b90c26b2927361b77799e751a6f9d602
MD5 0253c69b02e838cb90d39c29e6d7030c
BLAKE2b-256 d349316af4990eee42190e418acd426657d6ec1891e7487d61632aabf07f0dcd

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