Nigerian Twitter Sentiment Analysis — Logistic Regression vs RNN vs LSTM vs AfroXLMR
# NaijaSenti — Nigerian Twitter Sentiment Analysis
Multilingual sentiment classification across four Nigerian languages: **Hausa, Igbo,
Nigerian Pidgin, and Yorùbá**. This project fine-tunes and compares four model
architectures on the NaijaSenti corpus, from classical ML to a pretrained
African language transformer.
## Live Demo
Try it on Hugging Face Spaces
> Note: The live demo runs Logistic Regression and LSTM. AfroXLMR (best model,
> 0.74 F1) is documented in the results table and available as a trained model
> on Hugging Face.
---
## Results
| Model | Overall Macro F1 | Hausa | Igbo | Pidgin | Yoruba |
|---------------------|------------------|-------|------|--------|--------|
| Logistic Regression | 0.69 | 0.71 | 0.73 | 0.44 | 0.68 |
| SimpleRNN | 0.69 | 0.72 | 0.74 | 0.38 | 0.69 |
| LSTM (V2) | 0.71 | 0.75 | 0.75 | 0.43 | 0.69 |
| **AfroXLMR** | **0.74** | 0.77 | 0.78 | 0.49 | 0.70 |
> **Note on Pidgin neutral:** The neutral class has only 72 training samples in
> Pidgin, causing consistent underperformance across all models. This is a known
> data limitation in the NaijaSenti corpus, not a modelling failure.
---
## Setup
**Requirements:** Python 3.10, pipenv
```bash
git clone
github.com
cd naija-sentiment
pipenv install
pipenv shell
```
Run notebooks in order: `01 → 02 → 03 → 04 → 05`
> AfroXLMR (notebook 05) requires a GPU. Training was done on Google Colab
> (T4 GPU, ~25 minutes). The notebook is fully runnable locally for inference
> only if model weights are downloaded from the releases section.
---
## Models
### Logistic Regression
Classical baseline with TF-IDF features. Aggressive text preprocessing:
lowercasing, URL removal, punctuation, emoji, stopword removal, and lemmatization.
### SimpleRNN
Keras sequential RNN with embedding layer. Minimal preprocessing (URLs and
emojis only) to preserv …