Skip to content

harini0905/Comment-Toxicity-Detection-Using-Deep-Learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Deep Learning for Comment Toxicity Detection with Streamlit

πŸ“Œ Project Overview

This project uses Deep Learning to automatically classify online comments as Toxic or Non-Toxic. The model helps identify harmful comments, enabling automated content moderation and safer online communities.

The project includes:

  • Data Exploration and Preprocessing
  • Exploratory Data Analysis (EDA)
  • Text Cleaning and Tokenization
  • Feature Extraction using Tokenizer & Padding
  • Deep Learning Model (LSTM)
  • Model Evaluation
  • Single Comment Prediction
  • Bulk Comment Prediction
  • Interactive Streamlit Dashboard
  • Model Serialization using Pickle

🎯 Problem Statement

Online communities and social media platforms generate millions of user comments every day. While these platforms encourage communication and engagement, they also face challenges from toxic comments such as harassment, hate speech, abusive language, and offensive content.

The objective of this project is to develop a Deep Learning-based Comment Toxicity Detection model that automatically classifies comments as Toxic or Non-Toxic. The model assists moderators by identifying harmful comments, enabling safer and healthier online communities.


πŸ“‚ Dataset Information

Dataset: train.csv

Features

Feature Description
comment_text User comment text
toxic Toxicity label (0 = Non-Toxic, 1 = Toxic)

πŸ› οΈ Technologies Used

  • Programming Language: Python
  • Data Manipulation: Pandas, NumPy
  • Visualization: Matplotlib
  • Machine Learning: Scikit-learn
  • Deep Learning: TensorFlow, Keras
  • Natural Language Processing: NLTK
  • Web Framework: Streamlit
  • Model Serialization: Pickle

πŸ“Š Project Workflow

Step 1: Data Loading

  • Load the dataset into a Pandas DataFrame.
  • Explore dataset dimensions.
  • Check column names and data types.

Step 2: Data Cleaning

  • Handle missing values.
  • Remove duplicate records.
  • Clean comment text.
  • Convert text to lowercase.

Step 3: Exploratory Data Analysis (EDA)

  • Class Distribution
  • Pie Chart
  • Comment Length Distribution

Step 4: Text Preprocessing

  • Remove punctuation
  • Remove special characters
  • Remove stopwords
  • Tokenization
  • Sequence Padding

Step 5: Model Development

The Deep Learning model consists of:

  • Embedding Layer
  • LSTM Layer
  • Dropout Layer
  • Dense Output Layer (Sigmoid)

Step 6: Model Evaluation

Evaluate the model using:

  • Accuracy
  • Loss
  • Prediction Results

Step 7: Save Model

Using Pickle:

  • tokenizer.pkl
  • toxicity_model.pkl

Step 8: Streamlit Application

Interactive application providing:

  • Home Page
  • Dashboard
  • Data Visualization
  • Single Comment Prediction
  • Bulk CSV Prediction
  • Model Performance

πŸ“ˆ Evaluation Metrics

Accuracy

Measures the percentage of correctly classified comments.

Higher accuracy indicates better model performance.


Binary Crossentropy Loss

Measures prediction error during model training.

Lower loss indicates better performance.


πŸ“· Streamlit Application Screenshots

🏠 Home Page


πŸ“Š Dashboard Overview


πŸ“ˆ Dashboard Summary


πŸ“Š Class Distribution


πŸ₯§ Toxic vs Non-Toxic Distribution


πŸ“ Comment Length Distribution


πŸ” Single Comment Prediction


πŸ“‚ Bulk Comment Prediction


πŸ“ Project Structure

COMMENT TOXICITY /
β”‚
β”œβ”€β”€ Report/
β”‚   └── Comment Toxicity Detection Report.pdf
β”‚
β”œβ”€β”€ Screenshots/
β”‚   β”œβ”€β”€ Home.png
β”‚   β”œβ”€β”€ Dashboard 1.png
β”‚   β”œβ”€β”€ Dashboard 2.png
β”‚   β”œβ”€β”€ Visualization 1.png
β”‚   β”œβ”€β”€ Visualization 2.png
β”‚   β”œβ”€β”€ Visualization 3.png
β”‚   β”œβ”€β”€ Single Prediction.png
β”‚   └── Bulk Prediction.png
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ comment analysis.ipynb
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ tokenizer.pkl
β”œβ”€β”€ toxicity_model.keras
β”œβ”€β”€ .gitignore

πŸ“‚ Dataset

The dataset used in this project is not included in the repository due to its large size.

Place the required dataset files (train.csv and test.csv) in the project directory before running the notebook or Streamlit application.


▢️ Running the Project

1. Clone Repository

git clone <repository-url>

2. Install Dependencies

pip install -r requirements.txt

3. Open Jupyter Notebook

jupyter notebook

Open:

comment analysis.ipynb

4. Run Streamlit Dashboard

streamlit run app.py

πŸ’Ό Business Applications

  • Social Media Platforms
  • Online Forums and Communities
  • Content Moderation Services
  • Brand Safety & Reputation Management
  • E-learning Platforms
  • News Websites and Media Outlets

πŸš€ Future Enhancements

  • Multi-Class Toxicity Classification
  • Transformer-based Models (BERT/RoBERTa)
  • Explainable AI (SHAP/LIME)
  • Cloud Deployment
  • Multilingual Toxicity Detection
  • Real-Time Moderation API

About

End-to-end Comment Toxicity Detection using Deep Learning , TensorFlow, NLP, and Streamlit with interactive visualization, single prediction, and bulk CSV prediction

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors