Skip to main content

ClassifAIer

coverage tests test_ratio

ClassifAIer is a Python library that combines scikit-learn classifiers with LangChain embedding libraries, enabling seamless text classification using embeddings from large language models. This library offers a user-friendly interface, allowing you to classify text data in a human-like manner.

Features

  • Embedding Support: Ability to work with embeddings from large language models like OpenAI and compatible with embeddings supported by LangChain.
  • Parametric Classifiers: Compatibility with a wide range of classifiers from scikit-learn (e.g., RandomForestClassifier, KNeighborsClassifier, etc.).
  • Easy to Use: Simplifies text classification tasks with a user-friendly API.
  • Save and Load: Allows you to save and reload trained models for reuse.

Requirements

To use this library, you need Python 3.7 or higher. The required packages will be automatically installed when you install this library.

  • scikit-learn
  • langchain-core
  • langchain
  • numpy

Installation

You can install the required libraries using the following command:

pip install ClassifAIer

Usage

from classifaier import ClassifAIer
from langchain.embeddings import OpenAIEmbeddings
from sklearn.ensemble import RandomForestClassifier

# Initialize the embedding provider
embedding_provider = OpenAIEmbeddings(api_key='YOUR_API_KEY')

random_forest_classifier_params = {
    "n_estimators": 100,
    "max_depth": None,
    "min_samples_split": 2,
    "min_samples_leaf": 1,
    "random_state": 42
}

random_forest_classifier = RandomForestClassifier(**random_forest_classifier_params)

# Create a classifier instance
classifier = ClassifAIer(embedding_provider=embedding_provider, classifier=random_forest_classifier)

# Prepare your data
texts = ["İspanya Birinci Futbol Ligi (La Liga) ekibi Athletic Bilbao, golcü oyuncusu Aritz Aduriz'in sözleşmesini bir yıllığına uzattı.", "Piyasalar ABD'nin enflasyon verilerine odaklandı."]
labels = ["spor", "ekonomi"]

# Train the model
classifier.fit(texts, labels)

# Make predictions
predictions = classifier.predict_all(["Fildişi Sahili Milli Takımı'nın Belçikalı teknik direktörü Marc Wilmots görevinden ayrıldı.", "Borsa, günü yükselişle tamamladı"])
print(predictions)  # Output: ['spor', 'ekonomi']

# Save the model
classifier.save("my_classifier.pkl")

# Load the model
loaded_classifier = ClassifAIer.load("my_classifier.pkl", embedding_provider)

Contributing

Contributions are welcome! If you have suggestions or improvements, please create a pull request or open an issue.

License

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

Release files for ClassifAIer 0.1.6

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

Source distribution (sdist)

Source distribution for ClassifAIer 0.1.6
File Size Uploaded
ClassifAIer-0.1.6.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ClassifAIer 0.1.6
File Interpreter ABI Platform
ClassifAIer-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / ClassifAIer-0.1.6.tar.gz

Download URL ClassifAIer-0.1.6.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
30ee36a9972aba9297070b5b05c8bfe6f21e77556e3d981da1d7ea43f2b79707
BLAKE2b-256 checksum
How to use checksums
5fe22d8e681ce52bcf32ae07594271aaed4441c7503741b47ce3dd71099e0fae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.17

Release files / ClassifAIer-0.1.6-py3-none-any.whl

Download URL ClassifAIer-0.1.6-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
122df3c4e0a8a489131307b57b6393180048ec9e05ff7304c8b38b0c411e841d
BLAKE2b-256 checksum
How to use checksums
3600337ec3a7267f6749fe5c6a65a347d0049b43ce562b188dfcdd1de1961f89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.17

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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