VoltIC/Hate-Speech-Detection-2
0
Hate Speech and Offensive Language Detection
This repository contains a Natural Language Processing (NLP) and Deep Learning pipeline designed to detect and classify social media text into three categories: Hate Speech, Offensive Language, or Neither.
Features
- Advanced Text Processing: Utilizes
TfidfVectorizer(up to trigrams) to extract meaningful features from raw text. - Dimensionality Reduction: Employs Principal Component Analysis (PCA) to reduce 10,000 text features to 100 principal components, ensuring high-speed training and inference.
- Multiple Classifiers Evaluated: Includes Logistic Regression, Support Vector Machines (SVM), and Multi-Layer Perceptrons (MLP).
- Deep Learning Model: A Custom Keras Sequential Neural Network optimized with Dropout layers, achieving ~89% accuracy.
Project Structure
EDA.ipynb: Exploratory Data Analysis of the text dataset.model.ipynb: Complete pipeline including TF-IDF vectorization, PCA reduction, model training, and evaluation.hate_speech_model.h5: The exported, trained Keras Deep Learning model.eda_modified_dataset.csv/labeled_data.csv: Datasets containing the labeled social media text.
Tech Stack
- Python 3
- TensorFlow / Keras
- Scikit-Learn
- Pandas & NumPy
- Matplotlib
Results
The Deep Neural Network achieved the following metrics on the test set:
- Accuracy: 88.6%
- F1-Score: 87.6%
- ROC-AUC: 89.4%
Getting Started
- Clone the repository.
- Install the required dependencies:
pip install -r requirements.txt(requirestensorflow,scikit-learn,pandas,numpy). - Run
model.ipynbto retrain the models or usehate_speech_model.h5for direct inference.
