- ๐ Assignment 2: Credit Limit Prediction & Financial Risk Analysis
- Credit Limit Prediction Project
- ๐ Dataset Description & Interactive Viewer
- ๐ ๏ธ Exploratory Data Analysis (EDA)
- ๐ Data-Driven Research Questions
- โ๏ธ Feature Engineering & Unsupervised Learning
- ๐ง Regression: Predicting Credit Capacity
- ๐ Classification: Risk Management Strategy
- ๐ Final Summary & Executive Insights
- Trained Models
- ๐ Reproduction & Usage
Interactive Demo
You can test the model with your own data here: Click here to use the Prediction App
๐ Dataset Snapshot
The model is trained on the Credit Card Defaulter Prediction Dataset. Below is a visual snapshot of the raw data structure:
| ID | LIMIT_BAL | SEX | EDUCATION | MARRIAGE | AGE | PAY_0 | PAY_2 | PAY_3 | ... | default |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 20000.0 | 2 | 2 | 1 | 24 | 2 | 2 | -1 | ... | 1 |
| 2 | 120000.0 | 2 | 2 | 2 | 26 | -1 | 2 | 0 | ... | 1 |
| 3 | 90000.0 | 2 | 2 | 2 | 34 | 0 | 0 | 0 | ... | 0 |
| 4 | 50000.0 | 2 | 2 | 1 | 37 | 0 | 0 | 0 | ... | 0 |
| 5 | 50000.0 | 1 | 2 | 1 | 57 | -1 | 0 | -1 | ... | 0 |
(Total: 30,000 instances, 25 features)
license: apache-2.0 datasets: - Omrilevi123/credit-card-defaulter-data language: - en metrics: - accuracy - precision - recall - f1 - r2 library_name: sklearn tags: - financial-risk - credit-card - classification - regression
๐ Assignment 2: Credit Limit Prediction & Financial Risk Analysis
๐ฎ Project Overview
This repository presents a comprehensive Machine Learning pipeline designed to predict Credit Limit Balances (LIMIT_BAL) for bank customers. The study covers the entire data science lifecycle: from raw data cleaning and Exploratory Data Analysis (EDA) to advanced unsupervised learning (Clustering) and supervised modeling (Regression and Classification).
The core objective is to identify the demographic and behavioral drivers that influence credit allocation and to build a robust model for risk assessment.
๐บ Presentation Video
[![Presentation Video]
Credit Limit Prediction Project
๐ Dataset Description & Interactive Viewer
The analysis is based on the UCI Credit Card Default Dataset (30,000 observations, 25 features). To explore the complete dataset with interactive scrolling and filtering, please visit our dedicated dataset repository:
๐ Click here to open the Interactive Dataset Viewer
๐ Data Dictionary
| Feature | Type | Description |
|---|---|---|
| LIMIT_BAL | Target | Amount of given credit (NT dollar). |
| SEX | Category | 1 = male; 2 = female. |
| EDUCATION | Category | 1 = graduate school; 2 = university; 3 = high school; 4 = others. |
| MARRIAGE | Category | 1 = married; 2 = single; 3 = others. |
| PAY_0 to PAY_6 | History | Repayment Status: -1: Paid duly 0: Revolving credit (min. payment made) 1-8: Payment delay for X months 9: Delay of 9+ months. |
| BILL_AMT | Numeric | Amount of bill statement (Sep - April). |
| PAY_AMT | Numeric | Amount of previous payment (Sep - April). |
๐ ๏ธ Exploratory Data Analysis (EDA)
Rigorous data cleaning was performed, mapping undocumented categories in EDUCATION and MARRIAGE to a standardized "Others" category.
Target Distribution & Outlier Detection
Figure 1: Distribution of the target variable LIMIT_BAL.
Analysis: The credit limit follows a right-skewed distribution. While most customers are assigned low-to-medium limits, a premium segment receives significantly higher capacities.
Figure 2: Boxplot identifying outliers in credit limits.
Analysis: Outliers represent high-net-worth individuals. We intentionally retained these observations to provide critical patterns for predicting the "High-Limit" class.
Feature Correlations
Figure 3: Pearson Correlation Heatmap.
Correlation Heatmap Analysis
The heatmap above illustrates the Pearson correlation coefficients between various customer features and the target variable, Credit Limit (LIMIT_BAL).
Key Insights:
- Financial Metrics:
BILL_AMT1(0.29) andPAY_AMT1(0.20) show the strongest positive correlations with the credit limit. This indicates that customers with higher past bill statements and consistent payment histories tend to receive higher credit limits. - Demographics:
- Education (-0.23): Shows the strongest negative correlation, suggesting that educational background is a significant factor in how the bank assigns credit limits.
- Age (0.14): Shows a moderate positive correlation, implying that older, more established customers generally have slightly higher limits.
- Feature Relationships: We can observe a notable negative correlation (-0.41) between
AGEandMARRIAGE. Identifying such relationships is crucial for detecting multicollinearity during the feature engineering phase.
๐ Data-Driven Research Questions
Q1: Does education level correlate with a higher credit limit?
Insight: Graduate school alumni receive the highest average limits. Higher education serves as a strong proxy for financial stability.
Q2: Is there a significant gender-based difference in credit limits?
Insight: Women in this dataset tend to have slightly higher median credit limits, potentially reflecting better repayment reliability.
Q3: Does marital status impact credit allocation?
Insight: Married individuals typically hold higher limits, likely due to perceived life stability or dual-income household benefits.
Q4: What is the combined effect of Education and Gender?
Insight: Highly educated women represent the segment with the highest average credit limits. The gender gap narrows as education levels decrease.
โ๏ธ Feature Engineering & Unsupervised Learning
K-Means Clustering
Figure 8: Customer segmentation results.
Methodology: I utilized K-Means Clustering to segment the customer base into distinct behavioral groups (e.g., "Safe Payers" vs. "High-Risk Spenders"). This cluster assignment was injected as a new feature to provide our supervised models with higher-level behavioral context.
๐ง Regression: Predicting Credit Capacity
I evaluated several models to predict the continuous numerical LIMIT_BAL:
- Winner: Random Forest Regressor ($R^2$: 0.472).
- Why? The Random Forest model successfully captured complex, non-linear interactions between payment status and demographic factors that linear models missed.
Figure 10: Feature Importance ranking.
Insight: The most recent payment status (PAY_0) is the strongest indicator for credit limit adjustments.
๐ Classification: Risk Management Strategy
I reframed the problem as a binary classification task to assist in automated "High vs. Low" credit approval decisions.
Figure 11: Distribution of Target Classes.
Strategy: A Median Split was applied, ensuring a perfectly balanced dataset (50/50). This prevents model bias toward a specific class.
Precision vs. Recall: The Banking Perspective
In credit scoring, a False Positive (giving a high limit to a risky customer) is much more dangerous than a False Negative (opportunity cost). Thus, we prioritized Precision to protect the bank's capital.
Figure 12: Confusion Matrices for classification evaluation.
Business Insight: The Random Forest Classifier achieved the highest Precision. In banking, this is vital as it minimizes "False Positives" โ the risk of approving high limits for unsuitable candidates.
Winner: Random Forest Classifier
- Accuracy: 81.7%
- Precision: Highest among all models, successfully minimizing critical False Positive errors.
๐ Final Summary & Executive Insights
This project demonstrates the transition from a traditional, static credit scoring approach to a dynamic, machine-learning-driven pipeline. By analyzing 30,000 observations, we have established that:
- Behavioral Dominance: Financial discipline, specifically the repayment status of the most recent month (
PAY_0), is a more powerful predictor of creditworthiness than traditional demographic factors like age or gender. - The Power of Non-Linearity: While linear models provided a basic baseline, the Random Forest algorithm's ability to capture complex feature interactions led to a 33% improvement in predictive power ($R^2$ from 0.35 to 0.47).
- Risk-Centric Modeling: By prioritizing Precision in our classification phase, we created a model that actively protects the bank's capital from high-risk defaults while maintaining an overall accuracy of 81.7%.
Strategic Recommendation: For future deployment, integrating the K-Means clustering segments into the manual review process will allow the bank to offer personalized credit products tailored to the specific behavioral profiles identified in this study.
Trained Models
You can download the trained models directly from the repository:
- Regression Model: credit_limit_regressor.pkl
- Classification Model: default_classifier.pkl
๐ Reproduction & Usage
To reproduce this project locally:
- Clone the Repository:
https://huggingface.co/Omrilevi123/credit-limit-prediction/blob/main/README.md