Logo Lanfrica

Jano-Esterhuizen/Sentiment-Analysis-Using-AfriSenti-Dataset

Domain:

natural language processing
Creator:
Jan
Host:
A Comparative Study of Multilingual Models for Low-Resource African Languages # Sentiment Analysis on African Languages Using Multilingual Transformers ## 📚 Project Overview This project explores the effectiveness of multilingual transformer models for sentiment classification in low-resource African languages. It compares four models—**mBERT**, **AfriBERTa**, **AfroXLMR**, and **XLM-Roberta**—on four languages: **Ibo**, **Nigerian-Pidgin**, **Mozambican-Portuguese**, and **Yoruba**, using the **AfriSenti dataset**. Explainability tools like **LIME** and **SHAP** are also integrated to help interpret model predictions and evaluate fairness. --- ## 💾 Dataset - **Source**: AfriSenti-SemEval Dataset (Muhammad et al., 2023) - **Languages Used**: Yoruba, Nigerian-Pidgin, Ibo, Mozambican-Portuguese - **Split**: 70% Training / 30% Test - **Labels**: `positive`, `neutral`, `negative` → Mapped to `0`, `1`, `2` --- ## 🧠 Models Used | Model | Description | |------------------------|--------------------------------------| | `bert-base-multilingual-cased` | mBERT: General multilingual transformer | | `castorini/afriberta_base` | AfriBERTa: Pretrained on African corpora | | `Davlan/afro-xlmr-base` | AfroXLMR: African-optimized XLM-R | | `xlm-roberta-base` | XLM-Roberta: Trained on 100+ languages | --- ## ⚙️ Installation & Environment Install required libraries: ```bash pip install transformers datasets scikit-learn lime shap wandb ``` Log in to Weights & Biases (optional): ```bash wandb login ``` --- ## 🚀 How to Run 1. Clone this repository and navigate to the project folder. 2. Open the notebook: ```bash jupyter notebook Project_Code_Final.ipynb ``` 3. The notebook includes: - Preprocessing - Zero-shot evaluation - Fine-tuning using Hugging Face Trainer - Evaluation (F1, AUC, Kappa, etc.) - Explainability (LIME, SHAP) --- ## 📈 Evaluation Metrics - Accuracy - Precision / Recall / F1 (Macro) - ROC AUC (OvR) - Cohen’s Kappa Baseline performance is compared with a majority-c …