Loan approval prediction
Predict whether a loan will be approved or default, handling imbalance and checking the model for unfair bias.
What you'll learn
- âClassification with imbalanced classes
- âROC-AUC and precision-recall
- âFairness checks and explainability
What you'll build
- âPipeline with imputation and encoding
- âLogistic regression vs gradient boosting
- âROC and PR curves
- âBias check across groups
Step-by-step guide
- 1
Dataset
A public loan dataset (for example a "loan prediction" or credit default dataset; read its description).
- 2
Missing values
SimpleImputer (median for numbers, most_frequent for categories) inside the pipeline.
- 3
Imbalance
Use class_weight="balanced" or SMOTE (imbalanced-learn) only on the training folds.
- 4
Models
LogisticRegression and HistGradientBoostingClassifier; StratifiedKFold cross-validation on ROC-AUC.
- 5
Evaluate
ROC and precision-recall curves; choose a threshold based on the cost of a bad loan vs a lost customer.
- 6
Explain
Permutation importance; for the final model, explain 3 individual predictions.
- 7
Fairness
Compare approval and error rates across a sensitive attribute (for example gender) and discuss what you would change.
đ Make it stand out
- +Calibrate probabilities
- +Simple API with FastAPI
- +Model card documenting limits