← All projects

Mortgage Default Prediction

The problem

A lender wants to know, before approving a mortgage, whether a borrower is likely to default. The only information available is age, marital status, annual income, mortgage amount and total amount paid so far.

Approach

  1. Split: 80/20 train/test split (240 training and 60 test records), with a fixed random seed so results are reproducible.
  2. Five classifiers: two K-Nearest Neighbors models (k = 5 and k = 10) and three entropy decision trees: a baseline, one with a minimum number of samples to split and one with a minimum number of samples per leaf.
  3. Evaluation: per-class precision and recall, weighted F1, accuracy and model complexity (k or number of leaves) on the same test set.
  4. Scoring: the selected model predicts 20 new applicants.

Bar chart of test accuracy by model: knn_5, knn_10 and the baseline tree at 77%, the min-samples-leaf tree at 61.7%

Results

  • Selected model: KNN with k = 5. It ties on accuracy (77%) with KNN k = 10 and the baseline tree, but has the best balance between classes (weighted F1 0.766, about 70% recall on defaults). KNN k = 10 caught only 59% of defaults.
  • Too much pruning hurts: forcing at least 50 samples per leaf collapsed the tree to 4 leaves, dropping accuracy to 61.7% and recall on defaults to 37%.
  • New applicants: 8 of 20 (40%) were flagged as likely to default, mostly younger applicants (24 to 31) with lower income and high mortgage-to-income ratios.

Limitations and next steps: the features were not scaled, which biases KNN toward the dollar columns (next: StandardScaler in a scikit-learn Pipeline); a 60-record test set is small, so cross-validation would give more stable estimates; and because missing a default costs more than a false alarm, class weights or threshold tuning to raise recall on defaults are worth testing. Results come from the original course run; the course dataset is not redistributed.