Credit risk · Classification · Streamlit
Bankruptcy Risk Prediction
An explainable early-warning model that ranks companies by bankruptcy risk from six qualitative ratings, built for credit teams who need to focus their due diligence.
- 0.996cross-validated score
- 147duplicate rows caught
- 5models compared and tuned
- −0.90competitiveness correlation
The problem
Lending to a company that later goes bankrupt is expensive; refusing a healthy one loses business. A credit team needs a quick, explainable way to rank applicants by risk.
The data
250 companies with six ratings (industrial, management and operating risk, financial flexibility, credibility, competitiveness) on a low/medium/high scale, and a bankruptcy label.
Approach
Caught a data-quality trap
Only 103 of the 250 rows were unique. Training on duplicates would leak identical rows into train and test and inflate the scores, so they were removed before splitting.
Handled imbalance correctly
SMOTE applied to the training set only, after a stratified 80/20 split.
Compared five models
Logistic Regression, Decision Tree, Random Forest, Gradient Boosting and SVM, with ROC and learning curves.
Tuned and deployed
GridSearchCV / RandomizedSearchCV pipelines, then a Streamlit app where users set the ratings and get a probability.
What I found
- Competitiveness (r = −0.90), credibility (−0.76) and financial flexibility (−0.75) almost completely separate the classes.
- The 'risk' ratings matter much less (r between +0.23 and +0.37).
- A simple Logistic Regression is as accurate as the complex models and fully explainable, so it's the recommended model.
| Model | Test accuracy (21 companies) | CV score (tuned) |
|---|---|---|
| Logistic Regression | 1.00 | 0.996 |
| Random Forest | 1.00 | 1.000 |
| SVM | 1.00 | 1.000 |
| Decision Tree | 0.95 | – |
The key insight
Near-perfect scores on 21 test companies would not hold on messy real-world credit data. The cross-validated scores and the feature analysis are the reliable part, and the explainable model is the one I'd put in front of a credit committee.
Limitations & next steps
- Small, very cleanly separable dataset.
- Next: validate on a larger, real credit dataset with financial ratios.