# TextPredict
[![python](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12|3.13-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org) ![PyPI - Version](https://img.shields.io/pypi/v/sentimentpredictor) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) [![Downloads](https://static.pepy.tech/badge/sentimentpredictor)](https://pepy.tech/project/textpredict)
![TextPredict Logo](https://raw.githubusercontent.com/ankit-aglawe/textpredict/main/assets/logo.png)
## 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
```sh
pip install textpredict
```
### Usage
#### Sentiment Analysis
```python
from textpredict import TextPredict
tp = TextPredict()
result = tp.analyse("I love using this package!", task="sentiment")
print(result)
```
#### Emotion Detection
```python
result = tp.analyse("I am excited about this!", task="emotion")
print(result)
```
#### Zero-Shot Classification
```python
result = tp.analyse(
"This package is great for zero-shot learning.",
task="zeroshot",
class_list=["positive", "negative", "neutral"],
)
print(result)
```
#### Fine-Tuning Models
```python
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
```python
metrics = tp.evaluate_model(task="sentiment", eval_data=dataset["test"])
print("Evaluation metrics:", metrics)
```
#### Saving and Loading Models
```python
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
- **GitHub Repository**: [Github](https://github.com/ankit-aglawe/textpredict)
- **PyPI Project**: [PYPI](https://pypi.org/project/textpredict/)
- **Documentation**: [Readthedocs](https://github.com/ankit-aglawe/sentimentpredictor#readme)
- **Source Code**: [Source Code](https://github.com/ankit-aglawe/sentimentpredictor)
- **Issue Tracker**: [Issue Tracker](https://github.com/ankit-aglawe/sentimentpredictor/issues)
Raw data
{
"_id": null,
"home_page": "https://github.com/ankit-aglawe/textpredict",
"name": "textpredict",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "text classification, emotion classification, sentiment analysis, text analysis, machine learning, NLP, transformers, data science, pre-trained models, text mining",
"author": "Ankit Aglawe",
"author_email": "aglawe.ankit@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f7/85/fd1c8d83c827a43fad16322a80de232bd35b28c190524c1b368f6f293e5b/textpredict-0.1.2.tar.gz",
"platform": null,
"description": "# TextPredict\n\n[![python](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12|3.13-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org) ![PyPI - Version](https://img.shields.io/pypi/v/sentimentpredictor) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit) [![Downloads](https://static.pepy.tech/badge/sentimentpredictor)](https://pepy.tech/project/textpredict)\n\n![TextPredict Logo](https://raw.githubusercontent.com/ankit-aglawe/textpredict/main/assets/logo.png)\n\n\n## Advanced Text Classification with Transformer Models\n\n**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).\n\n### Features\n\n- **Sentiment Analysis**: Classify text based on sentiment with high accuracy.\n- **Emotion Detection**: Detect emotions in text effortlessly.\n- **Zero-Shot Classification**: Classify text into unseen categories without any additional training.\n- **Fine-Tuning**: Easily fine-tune models to improve performance on specific datasets.\n- **Model Evaluation**: Evaluate model performance with robust metrics.\n- **Distributed Training**: Support for distributed training to leverage multiple GPUs.\n\n### Installation\n\n```sh\npip install textpredict\n```\n\n### Usage\n\n#### Sentiment Analysis\n\n```python\nfrom textpredict import TextPredict\n\ntp = TextPredict()\nresult = tp.analyse(\"I love using this package!\", task=\"sentiment\")\nprint(result)\n```\n\n#### Emotion Detection\n\n```python\nresult = tp.analyse(\"I am excited about this!\", task=\"emotion\")\nprint(result)\n```\n\n#### Zero-Shot Classification\n\n```python\nresult = tp.analyse(\n \"This package is great for zero-shot learning.\",\n task=\"zeroshot\",\n class_list=[\"positive\", \"negative\", \"neutral\"],\n)\nprint(result)\n```\n\n#### Fine-Tuning Models\n\n```python\nfrom datasets import load_dataset\n\n# Load dataset\ndataset = load_dataset(\"imdb\")\n\n# Fine-tune model\ntp.tune_model(\n task=\"sentiment\",\n training_data=dataset[\"train\"],\n eval_data=dataset[\"test\"],\n num_train_epochs=1,\n batch_size=8,\n learning_rate=2e-5,\n early_stopping_patience=3,\n)\n```\n\n#### Evaluating Models\n\n```python\nmetrics = tp.evaluate_model(task=\"sentiment\", eval_data=dataset[\"test\"])\nprint(\"Evaluation metrics:\", metrics)\n```\n\n#### Saving and Loading Models\n\n```python\ntp.save_model(task=\"sentiment\", output_dir=\"./fine_tuned_sentiment_model\")\ntp.load_model(task=\"sentiment\", model_dir=\"./fine_tuned_sentiment_model\")\nresult = tp.analyse(\"I love using this package after fine-tuning!\", task=\"sentiment\")\nprint(result)\n```\n\n\n### Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.\n\n### License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n### Links\n\n- **GitHub Repository**: [Github](https://github.com/ankit-aglawe/textpredict)\n- **PyPI Project**: [PYPI](https://pypi.org/project/textpredict/)\n- **Documentation**: [Readthedocs](https://github.com/ankit-aglawe/sentimentpredictor#readme)\n- **Source Code**: [Source Code](https://github.com/ankit-aglawe/sentimentpredictor)\n- **Issue Tracker**: [Issue Tracker](https://github.com/ankit-aglawe/sentimentpredictor/issues)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for text classification using transformer models.",
"version": "0.1.2",
"project_urls": {
"Changelog": "https://github.com/ankit-aglawe/textpredict/releases",
"Documentation": "https://github.com/ankit-aglawe/textpredict#readme",
"Homepage": "https://github.com/ankit-aglawe/textpredict",
"Repository": "https://github.com/ankit-aglawe/textpredict",
"Source": "https://github.com/ankit-aglawe/textpredict",
"Tracker": "https://github.com/ankit-aglawe/textpredict/issues"
},
"split_keywords": [
"text classification",
" emotion classification",
" sentiment analysis",
" text analysis",
" machine learning",
" nlp",
" transformers",
" data science",
" pre-trained models",
" text mining"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "21e9a8b65d418776fdf84488c716ed02dcea20c9b079a93da6eaca5ea3bb5a86",
"md5": "edf0e74b9bc7f8b181ba649a5ac26412",
"sha256": "9cbc9cd94566d702f61d15edaeb44523ddf8576cc3d9509e70ee3b5da0e957ea"
},
"downloads": -1,
"filename": "textpredict-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "edf0e74b9bc7f8b181ba649a5ac26412",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 24358,
"upload_time": "2024-07-05T14:14:24",
"upload_time_iso_8601": "2024-07-05T14:14:24.534778Z",
"url": "https://files.pythonhosted.org/packages/21/e9/a8b65d418776fdf84488c716ed02dcea20c9b079a93da6eaca5ea3bb5a86/textpredict-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f785fd1c8d83c827a43fad16322a80de232bd35b28c190524c1b368f6f293e5b",
"md5": "0453d7148500fc9ddd1dab477666072c",
"sha256": "893a0c238d9b0af46ffd22e3e043346ea9e35c4015efa734053551e95644f868"
},
"downloads": -1,
"filename": "textpredict-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "0453d7148500fc9ddd1dab477666072c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 17034,
"upload_time": "2024-07-05T14:14:59",
"upload_time_iso_8601": "2024-07-05T14:14:59.127357Z",
"url": "https://files.pythonhosted.org/packages/f7/85/fd1c8d83c827a43fad16322a80de232bd35b28c190524c1b368f6f293e5b/textpredict-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-05 14:14:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ankit-aglawe",
"github_project": "textpredict",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "textpredict"
}