Skip to main content

A Python library for classifying toxic comments using deep learning. It supports detecting multiple types of toxicity including obscene language, threats, and identity hate.

Project description

Toxic Comment Classifier

GitHub license Python version PyPI version Downloads

# Toxic Comment Classifier

A Python library for classifying toxic comments using deep learning.
It supports detecting multiple types of toxicity including obscene language, threats, and identity hate.

📦 Installation

pip install toxic-comment-classifier

🚀 Usage

🔹 Import and Initialize the Model

from toxic_classifier.model import ToxicCommentClassifier

# Load the classifier
model = ToxicCommentClassifier()

🔹 Classify a Single Comment

text = "You are so dumb and stupid!"
scores = model.classify(text)

print("Toxicity Scores:", scores)

Example Output:

{
    'toxic': 0.5004,
    'severe_toxic': 0.4987,
    'obscene': 0.4989,
    'threat': 0.5021,
    'insult': 0.4979,
    'identity_hate': 0.5006
}

🔹 Get Overall Toxicity Score

toxicity = model.predict(text)
print(f"Overall Toxicity Score: {toxicity:.4f}")

Example Output:

Overall Toxicity Score: 0.4998

🔹 Classify Multiple Comments

texts = [
    "I hate this!",
    "You're amazing!",
    "This is the worst thing ever!"
]

scores = model.predict_batch(texts)

for txt, score in zip(texts, scores):
    print(f"Text: {txt} --> Toxicity Score: {score:.4f}")

Example Output:

Text: I hate this! --> Toxicity Score: 0.5002
Text: You're amazing! --> Toxicity Score: 0.5000
Text: This is the worst thing ever! --> Toxicity Score: 0.5008

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

toxic_comment_classifier-0.2.2.tar.gz (8.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toxic_comment_classifier-0.2.2-py3-none-any.whl (8.1 MB view details)

Uploaded Python 3

File details

Details for the file toxic_comment_classifier-0.2.2.tar.gz.

File metadata

File hashes

Hashes for toxic_comment_classifier-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0a31db74b2cb616790c3909bd2d9031bec1c2b3bd226f21d75a81c6894681ca9
MD5 c29fda0ef62568faf7bf761e902ce26a
BLAKE2b-256 0fd2cc02e2ca5501d82b21665dc58d59d583db5dd4445da658a0662ed9c09400

See more details on using hashes here.

File details

Details for the file toxic_comment_classifier-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for toxic_comment_classifier-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4fd0063cb514d01f1e5bb35fdabb96c94834c6c871e01fd2210e1721996dbb81
MD5 ce5a666c9a072d1eba1dc593b59daa5f
BLAKE2b-256 c5bdbb37f146897a45bb58bdf3e9d2bfd64d7792c8ef832904bef22a80daac60

See more details on using hashes here.

Supported by

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