CoolFace
Datasetpublic

22-pinkee/Home-Credit-Risk-Analysis

🏦 Home Credit Risk Analysis β€” EDA, Feature Engineering & ML Models This project explores the Home Credit Default Risk dataset throughEDA, statistical insights, feature engineering, clustering, regression, and classification modeling. The goals of the project are to: Understand borrower behavior and key risk drivers Predict missing creditworthiness scores (EXT_SOURCE_2) Develop a classification model to predict loan default Deploy both models via HuggingFace for… See the full description on the dataset page: https://huggingface.co/datasets/22-pinkee/Home-Credit-Risk-Analysis.

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes87downloads
Dataset Card

🏦 Home Credit Risk Analysis β€” EDA, Feature Engineering & ML Models

This project explores the Home Credit Default Risk dataset through EDA, statistical insights, feature engineering, clustering, regression, and classification modeling.

The goals of the project are to:

  • β€”Understand borrower behavior and key risk drivers
  • β€”Predict missing creditworthiness scores (EXTSOURCE2)
  • β€”Develop a classification model to predict loan default
  • β€”Deploy both models via HuggingFace for reproducibility

πŸ“Š Dataset Overview

After extensive cleaning, the dataset contains:

  • β€”307,511 rows, with all features engineered and cleaned
  • β€”Strong target imbalance: 92% non-default vs 8% default

βœ” Data Cleaning Summary

To prepare the data for analysis and modeling:

  • β€”Removed irrelevant or unusable columns
  • β€”Dropped features with excessive missing values
  • β€”Imputed missing values (numeric & categorical)
  • β€”Treated outliers via percentile capping
  • β€”Added missing-value indicators
  • β€”Ensured consistent feature formats for ML

This provided a stable, reliable dataset for EDA and modeling.


πŸ“Œ Project Structure

  1. 1.EDA & Research Questions
  2. 2.Data Cleaning Summary
  3. 3.Feature Engineering
  4. 4.Clustering (K-Means + PCA)
  5. 5.Regression Model β€” Predicting EXT_SOURCE_2
  6. 6.Classification Model β€” Predicting Default (TARGET)
  7. 7.Model Deployment (HuggingFace)
  8. 8.Key Insights, Limitations & Future Work

πŸ” 1. Exploratory Data Analysis (EDA)

We explored the dataset through seven core research questions.


1️⃣ Does EXT_SOURCE_2 differentiate between borrowers who default?

[image]

Interpretation: Borrowers who did not default show consistently higher EXT_SOURCE_2 scores. This variable is a strong risk separator.


2️⃣ Which borrower characteristics most strongly influence EXT_SOURCE_2?

[image]

Interpretation: Income, employment stability, demographic factors, and document counts correlate significantly with EXTSOURCE2.


3️⃣ Does borrower age affect default risk?

[image]

Interpretation: Younger borrowers default more often. Default probability declines steadily with age until ~60.


4️⃣ Does education level impact loan default risk?

[image]

Interpretation: Lower education levels correlate with a higher chance of default.


5️⃣ Is family status associated with different default probabilities?

[image]

Interpretation: Single and separated borrowers show elevated risk compared to married borrowers.


6️⃣ Does occupation type influence default likelihood?

[image]

Interpretation: Laborers and low-skill job categories have substantially higher default rates.


7️⃣ Does income level predict default probability?

[image]

Interpretation: Higher income strongly reduces default risk, making it one of the strongest predictors.


🧱 2. Feature Engineering

A structured pipeline generated several predictive feature groups:

βœ” Financial Ratios

  • β€”Credit / Income
  • β€”Annuity / Income
  • β€”Debt burden indicators

βœ” Stability Features

  • β€”Employment duration
  • β€”Stability measures
  • β€”Dependents / family load

βœ” Missingness Indicators

  • β€”MISSING_COUNT
  • β€”Boolean missing flags

βœ” Document Indicators

  • β€”DOCUMENT_COUNT

βœ” K-Means Cluster Features

  • β€”CLUSTER_ID
  • β€”CLUSTER_DIST

These clusters captured non-linear borrower patterns and improved model performance.


🧭 3. Clustering (K-Means + PCA)

Borrowers were clustered to reveal hidden behavioral groups.

PCA Cluster Spread

[image]

PCA Cluster Projection

[image]

Insight: Clusters displayed distinct financial & demographic traits. Including CLUSTER_ID and CLUSTER_DIST improved downstream model performance.


πŸ“ˆ 4. Regression Model β€” Predicting EXTSOURCE2

Model: Random Forest Regressor

Trained on a 50,000-row sampled dataset for robustness and efficiency.

Performance (Test Set)

  • β€”MAE: ~0.138
  • β€”RMSE: ~0.170
  • β€”RΒ²: ~0.21

Interpretation: The regression model captures meaningful signals in a noisy variable and significantly outperforms linear methods.

πŸ“Œ Model Deployment

πŸ”— https://huggingface.co/guyshilo12/guyshilo-loan-default-regression-model


πŸ›‘ 5. Classification Model β€” Predicting Default (TARGET)

Model: Random Forest Classifier

Trained with strong emphasis on recall, the most important metric in credit-risk decisioning.

Performance (Test Set)

  • β€”Accuracy: ~0.71
  • β€”Precision: ~0.165
  • β€”Recall: ~0.638
  • β€”ROC-AUC: ~0.739

Interpretation: Recall is prioritized because missing a risky borrower (false negative) is far more costly than misclassifying a safe borrower.

πŸ“Œ Model Deployment

πŸ”— https://huggingface.co/guyshilo12/home-credit-default-classifier


🌟 Key Insights & Conclusions

  • β€”EXTSOURCE2 and income are among the most influential predictors.
  • β€”Age, education, and occupation show strong default risk patterns.
  • β€”Missing values themselves contain valuable predictive information.
  • β€”Non-linear algorithms (Random Forest) outperform linear models significantly.
  • β€”Cluster features improved both regression and classification models.

⚠️ Limitations

  • β€”EXTSOURCE2 contains intrinsic noise β†’ limits regression accuracy.
  • β€”K-Means assumes spherical clusters; real borrower structure is more complex.
  • β€”Random Forests lack full model interpretability.
  • β€”Class imbalance reduces precision despite optimized recall.

🧩 Project Files

If you wish to explore the analysis further, the full notebook is included in the repository. [image] [image]

video walkthrough

you can watch the full video walkthrough here: https://drive.google.com/file/d/1NoT0LF52VE7FY8g7UtvIwXnPUXLgJM_i/view?usp=sharing


πŸ“„ License

MIT License