Downloads · 30 days
0
guyshilo12/guyshilo-loan-default-regression-model
guyshilo-loan-default-regression-model is a machine learning model from guyshilo12. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This repository contains the winning regression model trained to predict the external credit score (EXTSOURCE2) in the Home Credit Default Risk dataset. The model uses extensive feature engineering and captures non-li…
Downloads · 30 days
0
Access
Public
Updated Dec 6, 2025
Repo size
3.6 MB
Likes
0
Public
Click a slice to open those files.
.pkl3.6 MB · 100%
From the Hugging Face model README
This repository contains the winning regression model trained to predict the external credit score (EXT_SOURCE_2) in the Home Credit Default Risk dataset.
The model uses extensive feature engineering and captures non-linear financial and demographic patterns using a Random Forest Regressor.
Both files must be used together for inference.
Task: Regression
Target: EXT_SOURCE_2 (external credit score proxy)
Model: RandomForestRegressor
EXT_SOURCE_2 is a powerful creditworthiness indicator in the Home Credit dataset.
However, it contains many missing values, and being able to predict it from other borrower features helps improve downstream models.
The model was trained on a heavily engineered dataset including:
MISSING_COUNTDOCUMENT_COUNT (how many documents applicant supplied)CLUSTER_IDCLUSTER_DISTThese help the model capture non-linear borrower profiles that ordinary linear regression cannot.
RandomForestRegressor(
n_estimators=80,
max_depth=12,
min_samples_leaf=50,
n_jobs=-1,
random_state=42
)
max_depth=12 → prevents overfitting
min_samples_leaf=50 → forces smoothing and stability
n_estimators=80 → balances accuracy and training speed
n_jobs=-1 → uses all CPU cores
Model trained on 50,000 sampled rows for fast and robust performance.
| Metric | Score |
|---|---|
| MAE | ~0.138 |
| MSE | ~0.0287 |
| RMSE | ~0.170 |
| R² | ~0.21 |
An R² ≈ 0.21 means the model captures some meaningful signal but the dataset contains a lot of noise.
Performance is much stronger than a linear model, which scored ~0.18 R².
The model benefits significantly from:
Ratio features
Missing-value patterns
K-Means cluster structure
✔ Outperformed Linear Regression on all metrics ✔ Handles non-linear interactions between income, credit, stability, and documents ✔ Much less sensitive to noise and missingness ✔ Best trade-off between accuracy, generalization, and speed
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="guyshilo12/guyshilo-loan-default-regression-model",
filename="regression_winner.pkl"
)
cols_path = hf_hub_download(
repo_id="guyshilo12/guyshilo-loan-default-regression-model",
filename="feature_columns.json"
)
import pickle, json
# Load model
with open("regression_winner.pkl", "rb") as f:
model = pickle.load(f)
# Load feature list
with open("feature_columns.json", "r") as f:
feature_cols = json.load(f)
import pandas as pd
# Example input (replace zeros with real values)
X = pd.DataFrame([{col: 0 for col in feature_cols}])
pred = model.predict(X)[0]
print("Predicted EXT_SOURCE_2:", pred)
This model is ideal for:
Academic ML projects
Feature engineering demonstrations
Credit-risk modeling research
Improving missing-value imputation strategies
Not intended for production lending decisions without regulatory review.