# krishnavamsi-04/home-credit-default-risk-prediction architecture

> Architecture diagram of the GitHub repository krishnavamsi-04/home-credit-default-risk-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krishnavamsi-04/home-credit-default-risk-prediction
- Repository: https://github.com/krishnavamsi-04/home-credit-default-risk-prediction

## Overview

This repository is a Home Credit loan-default risk modeling project, with a small inference script that scores one applicant using saved preprocessing state and an XGBoost model. The documented workflow moves from exploratory analysis and a baseline through model comparison, tuning, cross-validation, and SHAP explainability, then corrects preprocessing leakage and saves artifacts for inference. The README documents notebook capabilities, but their internal calls are not available here; those relationships are shown only where the README supports them. Phase 3 API and frontend are planned, not implemented.

Main entry points: [`notebooks/phase1b_leakage_fix.ipynb`](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase1b_leakage_fix.ipynb) (Leakage correction), [`predict.py`](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/predict.py) (Feature preprocessing), [`notebooks/phase2_modeling.ipynb`](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase2_modeling.ipynb) (Model comparisons), [`notebooks/phase1_eda_baseline.ipynb`](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase1_eda_baseline.ipynb) (EDA and baseline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Analysis and baseline"]
  node_eda["EDA and baseline"]
  node_leakage["Leakage correction"]
end

subgraph group_modeling["Modeling and explainability"]
  node_modeling_nb["Model comparisons"]
  node_tuning["Tuning and validation"]
  node_shap["SHAP explanations"]
end

subgraph group_artifacts["Saved inference artifacts"]
  node_medians["Imputation medians<br/>[medians.pkl]"]
  node_freq_maps["Frequency maps<br/>[freq_maps.pkl]"]
  node_columns["Training columns<br/>[train_columns.pkl]"]
  node_config["Preprocessing config<br/>[config.pkl]"]
  node_xgb_model["XGBoost model<br/>[xgb_model.json]"]
end

subgraph group_inference["Applicant scoring"]
  node_cli["Score CLI<br/>[predict.py]"]
  node_preprocess["Feature preprocessing<br/>[predict.py]"]
  node_scoring["Risk scoring<br/>[predict.py]"]
end

node_dataset["Home Credit data"]
node_applicant(("Applicant"))
node_risk_score["Risk score"]

node_dataset -->|"analyzed in"| node_eda
node_dataset -->|"used for modeling"| node_modeling_nb
node_dataset -->|"read by"| node_leakage
node_eda -->|"followed by"| node_modeling_nb
node_modeling_nb -->|"tunes models"| node_tuning
node_modeling_nb -->|"explains model"| node_shap
node_leakage -->|"saves"| node_medians
node_leakage -->|"saves"| node_freq_maps
node_leakage -->|"saves"| node_columns
node_leakage -->|"saves"| node_config
node_leakage -->|"saves"| node_xgb_model
node_applicant -->|"provides input"| node_cli
node_cli -->|"calls"| node_preprocess
node_preprocess -->|"loads"| node_medians
node_preprocess -->|"loads"| node_freq_maps
node_preprocess -->|"aligns features"| node_columns
node_preprocess -->|"uses settings"| node_config
node_cli -->|"calls"| node_scoring
node_scoring -->|"prepares features"| node_preprocess
node_scoring -->|"scores with"| node_xgb_model
node_scoring -->|"returns score"| node_risk_score

click node_eda "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase1_eda_baseline.ipynb"
click node_leakage "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase1b_leakage_fix.ipynb"
click node_modeling_nb "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase2_modeling.ipynb"
click node_tuning "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase2_modeling.ipynb"
click node_shap "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase2_modeling.ipynb"
click node_medians "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/medians.pkl"
click node_freq_maps "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/freq_maps.pkl"
click node_columns "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/train_columns.pkl"
click node_config "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/config.pkl"
click node_xgb_model "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/xgb_model.json"
click node_cli "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/predict.py"
click node_preprocess "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/predict.py"
click node_scoring "https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/predict.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_eda,node_leakage toneBlue
class node_modeling_nb,node_tuning,node_shap toneAmber
class node_medians,node_freq_maps,node_columns,node_config,node_xgb_model toneMint
class node_cli,node_preprocess,node_scoring toneRose
class node_dataset,node_applicant,node_risk_score toneIndigo
```

## Components

### Analysis and baseline

- [EDA and baseline](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase1_eda_baseline.ipynb): `notebooks/phase1_eda_baseline.ipynb`
- [Leakage correction](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase1b_leakage_fix.ipynb): `notebooks/phase1b_leakage_fix.ipynb`

### Modeling and explainability

- [Model comparisons](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase2_modeling.ipynb): `notebooks/phase2_modeling.ipynb`
- [Tuning and validation](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase2_modeling.ipynb): `notebooks/phase2_modeling.ipynb`
- [SHAP explanations](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/notebooks/phase2_modeling.ipynb): `notebooks/phase2_modeling.ipynb`

### Saved inference artifacts

- [Imputation medians](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/medians.pkl): `artifacts/medians.pkl`
- [Frequency maps](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/freq_maps.pkl): `artifacts/freq_maps.pkl`
- [Training columns](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/train_columns.pkl): `artifacts/train_columns.pkl`
- [Preprocessing config](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/config.pkl): `artifacts/config.pkl`
- [XGBoost model](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/artifacts/xgb_model.json): `artifacts/xgb_model.json`

### Applicant scoring

- [Score CLI](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/predict.py): `predict.py`
- [Feature preprocessing](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/predict.py): `predict.py`
- [Risk scoring](https://github.com/krishnavamsi-04/home-credit-default-risk-prediction/blob/main/predict.py): `predict.py`

### Other components

- **Home Credit data**
- **Applicant**
- **Risk score**

## Connections

- Home Credit data → EDA and baseline: analyzed in (evidence: `README.md`)
- Home Credit data → Model comparisons: used for modeling (evidence: `README.md`)
- Home Credit data → Leakage correction: read by (evidence: `README.md`)
- EDA and baseline → Model comparisons: followed by (evidence: `README.md`)
- Model comparisons → Tuning and validation: tunes models (evidence: `README.md`)
- Model comparisons → SHAP explanations: explains model (evidence: `README.md`)
- Leakage correction → Imputation medians: saves (evidence: `README.md`)
- Leakage correction → Frequency maps: saves (evidence: `README.md`)
- Leakage correction → Training columns: saves (evidence: `README.md`)
- Leakage correction → Preprocessing config: saves (evidence: `README.md`)
- Leakage correction → XGBoost model: saves (evidence: `README.md`)
- Applicant → Score CLI: provides input (evidence: `predict.py`)
- Score CLI → Feature preprocessing: calls (evidence: `predict.py`)
- Feature preprocessing → Imputation medians: loads (evidence: `predict.py`)
- Feature preprocessing → Frequency maps: loads (evidence: `predict.py`)
- Feature preprocessing → Training columns: aligns features (evidence: `predict.py`)
- Feature preprocessing → Preprocessing config: uses settings (evidence: `predict.py`)
- Score CLI → Risk scoring: calls (evidence: `predict.py`)
- Risk scoring → Feature preprocessing: prepares features (evidence: `predict.py`)
- Risk scoring → XGBoost model: scores with (evidence: `predict.py`)
- Risk scoring → Risk score: returns score (evidence: `predict.py`)
