Skip to content

Repository files navigation

Hate Speech Classification — Model Comparison

Comparative study of 8 classifiers on a hate-speech dataset — from classical ML baselines to sequence models and transformer-based sentiment.

Accompanied by a small Flask demo for interactive prediction.

Stack: Python · scikit-learn · TensorFlow / Keras · Hugging Face · Flask · Jupyter


Models compared

# Model Notebook
1 Logistic Regression LogisticRegression.ipynb
2 Multinomial Naive Bayes MultinomialNaiveBayes.ipynb
3 Support Vector Machine SVM.ipynb
4 Random Forest RandomForest.ipynb
5 Gradient Boosting GradientBoosting.ipynb
6 XGBoost XGBoost.ipynb
7 LSTM (deep sequence model) LSTM.ipynb
8 Transformer + VADER (sentiment-augmented) Transformer(VADER).ipynb

Full write-up: Report.pdf


Results

Model accuracy comparison

Add assets/results.png — a matplotlib bar chart of accuracy / F1 for all 8 models, generated from your notebooks.

Fill this table with the numbers from your notebooks / Report.pdf:

Model Accuracy Precision Recall F1
Logistic Regression
Multinomial NB
SVM
Random Forest
Gradient Boosting
XGBoost
LSTM
Transformer + VADER

Winner: (fill in — which model performed best, and why you think so)


Dataset

  • File: hate.csv
  • Source: (add original source — Kaggle URL or paper reference)
  • Size: (rows)
  • Class balance: (class distribution — hate vs. non-hate)

Preprocessing pipeline

Documented in DataCleaning and EDA.ipynb:

  1. Lowercase + strip URLs / mentions / hashtags
  2. Tokenize
  3. Remove stopwords
  4. Lemmatize
  5. Vectorize
    • Classical models → TF-IDF
    • LSTM → learned embeddings
    • Transformer → pretrained embeddings + VADER sentiment features

Train/test split

See Train-Test Split.ipynb — stratified 80/20 split with a fixed random seed for reproducibility across all notebooks.


Setup

git clone https://github.com/prayas17/hate-speech-classification.git
cd hate-speech-classification
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate

pip install -r requirements.txt
jupyter lab

Run notebooks in this order:

  1. DataCleaning and EDA.ipynb
  2. Train-Test Split.ipynb
  3. Any model notebook (they're independent from here on)

Flask demo

A small web app that takes text input and returns a prediction using the best-performing model.

cd Flask
python app.py
# → open http://localhost:5000

Repo layout

.
├── DataCleaning and EDA.ipynb
├── Train-Test Split.ipynb
├── LogisticRegression.ipynb
├── MultinomialNaiveBayes.ipynb
├── SVM.ipynb
├── RandomForest.ipynb
├── GradientBoosting.ipynb
├── XGBoost.ipynb
├── LSTM.ipynb
├── Transformer(VADER).ipynb
├── hate.csv
├── Report.pdf
├── requirements.txt
├── Flask/                # Flask demo app
└── assets/
    └── results.png       # comparison chart

License

MIT

About

Comparative study of 8 classifiers (LR, MNB, SVM, RF, GBM, XGBoost, LSTM, Transformer/VADER) on a hate-speech dataset — with a Flask demo.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages