# Hausa Sentiment Analysis for Ghana π¬π
> **Machine Learning-Based Sentiment Analysis for Hausa Social Media Content in Ghana**
> Department of Computer Science Β· Research Project Β· 2026
---
## Overview
This project builds a supervised machine learning pipeline that classifies
Hausa-language text from social media and news sources into three sentiment
classes: **positive**, **negative**, and **neutral**.
The pipeline is designed around two complementary goals:
1. **Academic benchmarking** β train and evaluate on the
AfriSenti Hausa dataset
so results can be compared against published state-of-the-art systems.
2. **Applied inference** β run the trained model on unlabelled Ghana-focused
Hausa news articles (scraped from BBC Hausa, VOA Hausa, and DW Hausa) to
analyse real-world sentiment trends relevant to Ghanaian communities.
---
## Architecture
```
Raw Text (TSV / CSV)
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β HausaTextPreprocessor (src/utils.py) β
β β’ Lowercase & strip noise β
β β’ Remove URLs / mentions / hashtags β
β β’ Normalise repeated characters β
β β’ Tokenise & remove stopwords β
ββββββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββΌβββββββββββ
β FeatureUnion β
β βββββββββββββββββ β
β β Char TF-IDF β β 3β5-grams
β β Word TF-IDF β β unigrams + bigrams
β β Length feat. β β scaled
β β Lexicon feat. β β 11 numeric features, scaled
β βββββββββββββββββ β
ββββββββββββ¬βββββββββββ
β
ββββββββββββΌβββββββββββ
β Classifier β
β MultinomialNB OR β
β LogisticRegression β
ββββββββββββ¬βββββββββββ
β
ββββββββββββΌβββββββββββ
β Predicted Label β
β positive / neutral β
β / negative β
βββββββββββββββββββββββ
```
---
## Results
All results below are from the **held-out AfriSenti Hausa test set** (5,303 samples).
| Model | Vectoriser | Accuracy | Macro-F1 | Macro-P | Macro-R |
|---|---|---|---|---|---|
| Multinomial NaΓ―ve Bayes | TF-IDF | 74.7% | 0.748 | 0.750 | 0.747 β¦