CoolFace
Modelpublic

Lyes930/home-credit-risk-model-v1

sourceHugging Facemitupdated 10mo agoView on Hugging Face
1likes
Model Card

Home Credit - Credit Risk Model Stability

Banner Framework Status

This repository contains the complete source code, pretrained models, and documentation for a State-of-the-Art (SOTA) credit risk stability model. The solution was developed for the Home Credit - Credit Risk Model Stability competition, focusing on predicting default probability while maintaining performance stability over time.

๐Ÿ† Key Performance

MetricScoreDescription
Stability Score0.67701Official competition metric (Gini with stability penalty).
AUC0.8308Raw predictive power (Single Fold).
Slope~0.00Performance degradation over time (near zero is ideal).

๐Ÿ“‚ Repository Structure

This project is organized as a production-ready Python package with clear separation of concerns.

text
.
โ”œโ”€โ”€ models/                 # Pretrained CatBoost models (10GB+)
โ”‚   โ”œโ”€โ”€ catboost_fold_1.cbm
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ src/                    # Core source code
โ”‚   โ”œโ”€โ”€ data/               # Polars-based data pipeline & aggregation logic
โ”‚   โ”œโ”€โ”€ features/           # Feature engineering & adversarial selection
โ”‚   โ”œโ”€โ”€ models/             # Trainer wrapper for CatBoost/LGBM
โ”‚   โ””โ”€โ”€ validation/         # Stability-aware cross-validation splitters
โ”œโ”€โ”€ notebooks/              # Experimentation labs (Jupyter)
โ”‚   โ”œโ”€โ”€ 01_baseline...      # Initial feasibility study
โ”‚   โ”œโ”€โ”€ 02_feature...       # Deep feature engineering (Depth 0/1/2)
โ”‚   โ”œโ”€โ”€ 05_champion...      # FINAL Training script (GPU required)
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ docs/                   # Detailed technical reports
โ”‚   โ””โ”€โ”€ reports/            # Technical evolution, summary, and appendices
โ”œโ”€โ”€ training_artifacts/     # Logs and OOF predictions
โ””โ”€โ”€ verify_model.py         # Quick inference verification script

๐Ÿš€ Getting Started

1. Prerequisites

  • โ€”Python 3.10+
  • โ€”NVIDIA GPU (Recommended for training, optional for inference)
  • โ€”RAM: 32GB+ (for full data processing)

2. Installation

Clone the repository and install dependencies. Note that this repo uses Git LFS for model weights.

bash
# Install Git LFS first
git lfs install

# Clone repository
git clone https://huggingface.co/Lyes930/home-credit-risk-model-v1
cd home-credit-risk-model-v1

# Install Python dependencies
pip install -r requirements.txt

3. Data Preparation

Due to licensing, the raw dataset cannot be hosted here. Please download it from Kaggle:

  1. 1.Go to the Competition Data Page.
  2. 2.Download and unzip the data.
  3. 3.Place the csv_files or parquet_files folders inside a data/ directory in the root of this repo.

Structure should look like:

text
data/
  โ”œโ”€โ”€ parquet_files/
  โ”‚   โ”œโ”€โ”€ train/
  โ”‚   โ””โ”€โ”€ test/
  โ””โ”€โ”€ feature_definitions.csv

๐Ÿ›  Usage

Inference (Verification)

To verify the pretrained models and run predictions on the training data (as a smoke test):

bash
python verify_model.py

This script will load the models from the root directory, generate features, and output the AUC score.

Training (Retrain from Scratch)

If you have a GPU environment, you can reproduce the training process:

  1. 1.Open notebooks/05_champion_optimization.ipynb.
  2. 2.Ensure your data/ directory is populated.
  3. 3.Run all cells. This will train 5 folds of CatBoost models and save them.

๐Ÿง  Technical Highlights

This solution differentiates itself through robust engineering rather than complex ensembles:

  1. 1.Polars Data Engine: Replaced Pandas with Polars to handle 1.5M rows x 1600 columns with highly efficient memory usage (Lazy API).
  2. 2.Depth-2 Aggregation: Implemented a double-aggregation strategy (Payment -> Contract -> User) to capture deep historical credit behavior.
  3. 3.Adversarial Validation: Used a time-based discriminator to remove features that drift significantly over time, ensuring model stability.
  4. 4.No "Metric Hacking": We proved that artificial score reduction (hacking) hurts performance on robust models. We stuck to honest probabilities.

For a deep dive into the architectural decisions, please read the Technical Evolution Path.


๐Ÿค Citation & Acknowledgements

If you use this code or ideas in your research, please cite:

bibtex
@misc{home-credit-risk-v1,
  author = {Lyes930},
  title = {Home Credit - Credit Risk Model Stability Solution},
  year = {2025},
  publisher = {Hugging Face},
  journal = {Hugging Face Model Hub},
  howpublished = {\url{https://huggingface.co/Lyes930/home-credit-risk-model-v1}}
}

Special thanks to the Kaggle community and Home Credit Group for the challenging dataset.