YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Project Walkthrough Video
BNPL Credit Risk Prediction Project
Project Overview
For this project, I worked with a Buy Now Pay Later (BNPL) credit risk dataset. The main idea was to understand customer risk and build models that can help predict it. The project includes data cleaning, exploratory data analysis, feature engineering, clustering, model training, and model evaluation.
Dataset Overview
The dataset has 10,345 rows and 17 columns. Each row represents a BNPL customer or transaction.
The dataset includes information such as age, employment type, monthly income, credit score, purchase amount, product category,
number of BNPL installments, app usage frequency, location, and risk score.
The main target for the regression part was risk_score. This means I wanted the model to predict a number that represents how risky a customer is.
Data Cleaning
The dataset was already clean. There were no missing values and no duplicate rows.
Exploratory Data Analysis
In the EDA, I tried to understand the data before building models. I looked at the target variable, risk_score, and found that
most customers had risk scores around the middle range.
I also checked which features seemed connected to risk. The clearest patterns were that customers with higher credit scores
usually had lower risk scores, and customers with higher monthly income usually had lower risk scores.
On the other hand, customers with more missed payments usually had higher risk scores.
Customers who delayed payments for more days also usually had higher risk scores.
Customers with higher debt compared to their income also seemed to be riskier.
The strongest relationship was between credit_score and risk_score. This made sense because credit score is usually a very important factor when checking customer risk.
Feature Engineering
After the EDA, I created a few new features to help the models understand the data better. The new features were purchase_to_income_ratio,
transaction_year, transaction_month, credit_score_group, and income_group.
The most useful new idea was purchase_to_income_ratio. This feature compares the purchase amount to the customer’s monthly income.
For example, a 4,000 purchase is very different for someone earning 8,000 a month compared to someone earning 80,000 a month.
So this feature gives more context than just looking at the purchase amount alone.
Clustering
I also used K-Means clustering. The purpose of clustering was to let the computer group similar customers together. I used customer information like income, credit score, purchase amount, installment count, app usage, and purchase to RKLBincome ratio. The clustering model created 3 customer groups. After checking the average values in each group, I found that Cluster 0 looked like the lowest risk group. These customers had higher income, higher credit scores, and the lowest average risk score. Cluster 1 looked like the highest-risk group. These customers had the lowest income, low credit scores, and the highest average risk score. Cluster 2 also looked risky. These customers had low income and large purchases compared to their income.
I added the cluster number as a new column called cluster. This gave the later models another useful feature: what type of customer group each person belongs to.
Regression Models
I first trained a simple baseline Linear Regression model. Then I trained three improved regression models: Linear Regression with engineered features, Decision Tree Regressor, and Random Forest Regressor. For the regression part, I compared four models. The baseline Linear Regression model performed well, with an MAE of 20.00, an RMSE of 24.64, and an R² score of 0.8653. After adding the engineered features, the Linear Regression model improved a bit. It had an MAE of 19.96, an RMSE of 24.59, and an R² score of 0.8658. The Decision Tree Regressor performed the worst out of the models. It had an MAE of 26.65, an RMSE of 34.37, and an R² score of 0.7379. The Random Forest Regressor performed close to the Linear Regression models, with an MAE of 20.36, an RMSE of 24.81, and an R² score of 0.8634.
Overall, the best regression model was Linear Regression with engineered features. The improvement over the baseline was small, but it still had the lowest error and the highest R² score.
Important Issue: Data Leakage
One important thing I noticed during the project was data leakage. Data leakage means the model is using information that it should not realistically have
when making a prediction.
At first, I included columns like repayment_delay_days, missed_payments, default_flag, and debt_to_income_ratio.
When I used those columns, the model gave almost perfect results. That looked good at first, but it was actually suspicious.
The reason is that these columns are very directly connected to the final risk score. For example, if a customer already missed payments or already defaulted,
then the model is almost being given the answer.
In a real BNPL decision, the company would usually want to predict risk before approving the customer, not after already seeing the repayment result. So I removed these columns from the final modeling features. This made the model more realistic and made the results more trustworthy.
Classification Models
For the classification task, I trained three models: Decision Tree Classifier, Random Forest Classifier, and Gradient Boosting Classifier. The goal was to predict whether each customer is Low Risk, Medium Risk, or High Risk. For the classification part, I compared three models. The Decision Tree Classifier had the lowest accuracy, about 73.4%. The Random Forest Classifier performed better, with an accuracy of about 80.4%. The Gradient Boosting Classifier performed the best, with an accuracy of about 80.6%. The difference between Random Forest and Gradient Boosting was very small, but Gradient Boosting had the highest score, so I chose it as the final classification model.
Precision, Recall, False Positives, and False Negatives
I think recall is more important than precision. The reason is that the main goal is to catch risky customers.
If the model misses a truly high-risk customer, the BNPL company may approve someone who is likely to pay late or not repay. That would be a bigger problem than being a little too careful with a customer. A false negative is more critical here. A false negative means the model says a customer is not high risk, but in reality the customer is high risk. That could lead to financial loss for the company. A false positive is also not ideal, because a good customer might be labeled as risky. But in this project, missing a risky customer is the bigger problem.
Final Models
The final regression model is Linear Regression with engineered features. The final classification model is Gradient Boosting Classifier.
Main Takeaways
The biggest takeaway from this project was that checking the data is just as important as training the models. At first, some models looked almost perfect, but that was because they were using columns that gave away too much information. After removing those columns, the results became more realistic. Another takeaway is that a more complex model is not always better. For regression, Linear Regression performed better than Decision Tree and Random Forest. For classification, Gradient Boosting performed the best, but Random Forest was very close.









