Back to Projects
NLP / Data Science· 2025

Arabic Dialect Classification

ML-based classification of Arabic dialects using TF-IDF and Logistic Regression

67%
Accuracy
95%
EG Precision
522
Dataset Size
4
Dialects
Problem

Arabic is spoken across many countries with significant dialectal variation. Understanding which dialect a text belongs to is essential for region-specific NLP applications, sentiment analysis, and content moderation — yet most NLP tools treat Arabic as a single language.

Solution

Built a machine learning pipeline to classify Arabic text into 4 dialects — Saudi (SA), Egyptian (EG), Syrian (SY), and Moroccan (MO) — using TF-IDF feature extraction and Logistic Regression, achieving 67% accuracy on a manually annotated 522-sample dataset.

Tech Stack

Pythonscikit-learnPandasNumPyMatplotlibTF-IDFLogistic Regression

Key Features

Custom Arabic text preprocessing pipeline — removes URLs, emojis, punctuation, and non-Arabic characters
Manual multi-annotator labeling (4 annotators) with majority vote for ground truth
Stratified train/test split (80/20) preserving dialect distribution
Handles 4 Arabic dialects: Saudi, Egyptian, Syrian, and Moroccan

Results

67% overall accuracy on 4-class dialect classification

95% precision on Egyptian dialect — highest per-class performance

90% recall on Saudi dialect — strong identification of the majority class

Complete end-to-end NLP pipeline from raw text to classification

Visualizations

Dialect Distribution — Dataset class balance across 4 Arabic dialects

Dialect Distribution — Dataset class balance across 4 Arabic dialects

Confusion Matrix — Model predictions vs true dialect labels

Confusion Matrix — Model predictions vs true dialect labels