CoolFace
Apppublic

VoltIC/Hate-Speech-Detection-2

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
App README

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

  1. 1.Clone the repository.
  2. 2.Install the required dependencies: pip install -r requirements.txt (requires tensorflow, scikit-learn, pandas, numpy).
  3. 3.Run model.ipynb to retrain the models or use hate_speech_model.h5 for direct inference.