Downloads · 30 days
0
guyshilo12/home-credit-default-classifier
home-credit-default-classifier 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 a machine-learning model trained to predict whether a borrower will default on a loan (TARGET = 1). The model is based on a feature-engineered version of the Home Credit Default Risk dataset a…
Downloads · 30 days
0
Access
Public
Updated Dec 6, 2025
Repo size
4.9 MB
Likes
0
Public
Click a slice to open those files.
.pkl4.9 MB · 100%
From the Hugging Face model README
This repository contains a machine-learning model trained to predict whether a borrower will default on a loan (TARGET = 1).
The model is based on a feature-engineered version of the Home Credit Default Risk dataset and is optimized to handle extremely imbalanced data.
The final model is a Random Forest Classifier, selected after evaluating multiple algorithms.
Both files must be used together for inference.
Task: Binary Classification
Labels:
0 → borrower predicted not to default1 → borrower predicted to defaultAlgorithm: RandomForestClassifier
RandomForestClassifier(
n_estimators=80,
max_depth=10,
min_samples_leaf=100,
n_jobs=-1,
random_state=42,
class_weight="balanced"
)
class_weight="balanced": Critical for dealing with the severe class imbalance (~92% non-default vs. ~8% default).min_samples_leaf=100: Reduces variance and prevents the model from learning noise specific to a few samples.max_depth=10: Limits tree complexity to ensure generalization.| Metric | Score |
|---|---|
| Accuracy | ~0.71 |
| Precision | ~0.165 |
| Recall | ~0.638 |
| F1 Score | ~0.263 |
| ROC-AUC | ~0.739 |
The model was trained on a feature-engineered dataset derived from the Home Credit competition. Key feature groups include:
CLUSTER_ID, CLUSTER_DIST) were added to capture non-linear borrower segments.from huggingface_hub import hf_hub_download
model_path = hf_hub_download(
repo_id="guyshilo12/home-credit-default-classifier",
filename="rf_classifier.pkl"
)
cols_path = hf_hub_download(
repo_id="guyshilo12/home-credit-default-classifier",
filename="feature_columns.json"
)
import pickle
import json
# Load model
with open("rf_classifier.pkl", "rb") as f:
model = pickle.load(f)
# Load feature order
with open("feature_columns.json", "r") as f:
feature_cols = json.load(f)
import pandas as pd
# Example input row (replace 0s with real feature values)
X = pd.DataFrame([{col: 0 for col in feature_cols}])
# Predict class and probability of default
pred = model.predict(X)[0]
proba = model.predict_proba(X)[:, 1][0]
print("Predicted class:", pred)
print("Default probability:", proba)
This model is suitable for:
Academic / university projects
Experiments on imbalanced classification
Credit-risk proof-of-concept models
Research on feature engineering and tabular ML
Not intended for real-world lending decisions, production use, or regulatory environments without proper validation, calibration, and compliance review.