Predicting repayment risk in "Buy Now, Pay Later" (BNPL) transactions using EDA, statistical testing, and machine learning — built as a lightweight risk-screening solution e-commerce platforms could use to offer BNPL safely, without an in-house risk team.
- 📊 Presentation: Google Slides
- 📈 Tableau Dashboard: BNPL Customer Risk Dashboard
- 🗂️ Dataset: BNPL Dataset on Kaggle
This project analyzes 50,000 synthetic BNPL transactions to answer one question: can transaction and customer data help identify which BNPL transactions are more likely to become at-risk?
The workflow covers:
- Data preparation — cleaning, target variable creation (
at_risk) - EDA & Hypothesis Testing — identifying and statistically confirming key risk drivers
- Tableau Dashboard — a self-serve BI tool for non-technical teams to monitor risk patterns
- Machine Learning — classification models to predict at-risk transactions
- Streamlit App — a live demo simulating a real-time checkout risk check
- Credit score and VPN connection type are the two statistically significant drivers of repayment risk (all other variables tested — gender, device type, browser, purchase category, income, purchase amount — showed no meaningful association).
- At-risk customers had a significantly lower average credit score (500.6) than non-at-risk customers (595.6).
- VPN connections showed a 43.5% at-risk rate, compared to ~21% for WiFi/4G-5G.
- A tuned Random Forest model (threshold = 0.40) was the best-performing classifier, reaching 80% Recall — prioritizing catching at-risk customers, the costliest error for a BNPL provider to miss.
| File | Description |
|---|---|
bnpl_analysis.ipynb |
Full analysis notebook — data cleaning, EDA, hypothesis testing, ML modeling, model evaluation |
app.py |
Streamlit app simulating a real-time BNPL risk check at checkout |
rf_model.pkl |
Trained, tuned Random Forest model (used by app.py) |
encoder.pkl |
Fitted OneHotEncoder for categorical features (used by app.py) |
README.md |
This file |
The app is not deployed — it's designed to run on your own machine. To try it:
-
Clone this repository:
git clone https://github.com/fran26m/bnpl-risk-project.git cd bnpl-risk-project -
Install the required packages:
pip install streamlit pandas scikit-learn
-
Run the app:
streamlit run app.py
-
The app will open automatically in your browser at
localhost:8501.
Note:
app.pyloadsrf_model.pklandencoder.pklfrom the same folder — make sure all three files stay together in the repo root.
- Python: pandas, scikit-learn, matplotlib, seaborn, scipy, statsmodels
- Visualization / BI: Tableau
- Web App: Streamlit
- Environment: Jupyter Notebook (Anaconda)
Juan Francisco Orona — Ironhack Data Analytics Bootcamp