Semantische Datenintelligenz
Dipl.-Ing. Börteçin EGE



Machine Learning Projects


Predicting Loan Approval with a Decision Tree

- A machine learning demo project in Python (scikit-learn)

Machine Learning Projects

View project on GitHub

What it's about

In this project, a machine learning model decides whether a loan application is likely to be approved or rejected — based on features such as credit history, income, requested amount, and employment status. The data is deliberately synthetic: a custom-written generator produces reproducible datasets with clearly defined, learnable patterns.

The approach

The complete ML workflow, cleanly structured:

  • Data generation and preprocessing as a pipeline - categorical features are encoded, and the whole thing is wrapped so that no test information leaks into training (avoiding data leakage).
  • Stratified train/test split - preserving the class distribution.
  • Evaluation beyond accuracy — confusion matrix, per-class precision/recall, and a comparison against the majority baseline.
  • Cross-validation for a robust performance estimate instead of a single, chance-dependent split.
  • Hyperparameter tuning with GridSearchCV.

  • The result

    The Decision Tree shows good overall predictive performance. The training accuracy (87.6%) is moderately higher than the test accuracy (82.2%), which may indicate slight overfitting. Since the dataset is moderately imbalanced, with approximately 66% positive and 34% negative cases, the model's performance should not be evaluated based on accuracy alone. The Confusion Matrix, as well as Precision (84.4%), Recall (90.0%), and the F1-Score (87.1%) for the positive class Y, confirm good predictive performance for this class. In addition, a ROC-AUC score of 0.786 indicates that the model has a fair to good ability to distinguish between classes Y and N. Feature importance analysis is used to examine which variables contributed most strongly to the Decision Tree's predictions: Credit history is by far the most important feature, followed by co-applicant income, loan amount, and applicant income. The remaining features have an importance of zero in this particular tree.

    Decision Tree


    Confusion Matrix