# First Neural Network - African Data Exploration
## 📌 Overview
This project builds and trains a **neural network using TensorFlow/Keras** on African economic data (GDP per capita, population, year) to predict **life expectancy**. It compares deep learning performance with traditional machine learning models (Linear Regression, Random Forest) and experiments with different architectures.
## 👤 Author
**Abdelaziz Abakar Tahir** - AISIP Cohort 1 (Africa AI Hub)
---
## 📊 Dataset
- **Source:** Gapminder / World Bank
- **Time period:** 1952 - 2007
- **Countries:** 54 African nations
- **Features:**
- `year` - Year of observation
- `pop` - Population
- `gdpPercap` - GDP per capita (USD)
- **Target:** `lifeExp` - Life expectancy (years)
- **Samples:** 576 rows
---
## 🧠Neural Network Architecture (Base Model)
| Layer | Type | Neurons | Activation |
|-------|------|---------|------------|
| Input | Dense | 64 | ReLU |
| Output | Dense | 1 | Linear |
- **Optimizer:** Adam (learning rate = 0.001)
- **Loss Function:** Mean Squared Error (MSE)
- **Metrics:** Mean Absolute Error (MAE)
- **Epochs:** 50
- **Batch Size:** 32
- **Validation Split:** 20%
---
## 📈 Loss Curves
*Left: Training vs Validation Loss (MSE) over 50 epochs*
*Right: Training vs Validation MAE over 50 epochs*
The curves show convergence with no significant overfitting, as both training and validation losses decrease together.
---
## 📊 Model Comparison Results
| Model | MSE | R² Score |
|-------|-----|----------|
| Neural Network (64 neurons) | 18.45 | 0.85 |
| Linear Regression | 22.31 | 0.82 |
| **Random Forest** | **12.67** | **0.89** |
**Key Finding:** Random Forest outperformed the neural network on this small tabular dataset (576 samples).
---
## 🧪 Experimentation Results
| Model | Architecture | MSE | R² Score |
|-------|--------------|-----|----------|
| Base Model | 64 neurons | 18.45 | 0.85 |
| + Hidden Layer + Dropout | 64 → 32 + Dropout(0.2) | 19.23 | 0.84 |
| Increased Neurons | 1 …