# 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 âŠ