# Africa Credit Challenge: Predicting Loan Default
This project tackles a real-world loan default prediction challenge using a dataset of loans from Kenya and Ghana. The goal was to build a machine learning model that can accurately identify high-risk loan applicants. The project covers the entire data science lifecycle: from in-depth exploratory data analysis and advanced feature engineering to model comparison and the creation of a practical, business-focused credit scoring system.
The final, champion model (XGBoost) was saved as a deployment-ready artifact.
---
## The Business Problem: Finding the Needle in the Haystack
The core challenge of this project lies in the **severe class imbalance** of the dataset. A staggering **98.2%** of loans were successfully paid back, while only a tiny fraction (**1.8%**) resulted in a default.
This creates two major problems:
1. **A "dumb" model can achieve 98% accuracy** by simply guessing "No Default" every time, making accuracy a useless metric. The true challenge is finding the rare defaulters.
2. The model's success must be measured by its ability to correctly identify this tiny minority of high-risk customers, making metrics like the **F1-Score** the primary indicator of performance.
## My Approach: A Step-by-Step guide
I followed a structured, end-to-end process to move from raw data to a functional, business-ready solution.
### 1. Exploratory Data Analysis (EDA)
I began with a deep dive into the data to uncover predictive patterns. The key findings were:
- New customers were found to be **over 10 times more likely to default** (a >20% default rate) compared to "Repeat Loan" customers (
- **Loan Characteristics Matter:** Certain loan_type categories (like Type_15 and Type_23) had extremely high default rates, some exceeding 70%, identifying them as high-risk products.
- **Financial Behavior Signals Risk:** On average, customers who defaulted tended to take out larger loans and for longer durations …