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
| # | 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
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)
- File:
hate.csv - Source: (add original source — Kaggle URL or paper reference)
- Size: (rows)
- Class balance: (class distribution — hate vs. non-hate)
Documented in DataCleaning and EDA.ipynb:
- Lowercase + strip URLs / mentions / hashtags
- Tokenize
- Remove stopwords
- Lemmatize
- Vectorize
- Classical models → TF-IDF
- LSTM → learned embeddings
- Transformer → pretrained embeddings + VADER sentiment features
See Train-Test Split.ipynb — stratified 80/20 split with a fixed random seed for reproducibility across all notebooks.
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 labRun notebooks in this order:
DataCleaning and EDA.ipynbTrain-Test Split.ipynb- Any model notebook (they're independent from here on)
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.
├── 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
MIT
