# ngtanphuc/home-credit-risk architecture

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

- Interactive diagram: https://gitdiagram.com/ngtanphuc/home-credit-risk
- Repository: https://github.com/ngtanphuc/home-credit-risk

## Overview

This is a scaffold for a Home Credit binary credit-risk research pipeline: applicant data is ingested and cleaned, features are built, models are compared and tuned, and final probabilities are evaluated and explained. The README documents this intended workflow and capabilities, but describes most modules as empty stubs; edges therefore reflect documented relationships, not inspected runtime calls.

Main entry points: [`src/cv/runner.py`](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/cv/runner.py) (Cross-validation runner), [`src/features/build.py`](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/build.py) (Feature builder), [`src/models`](https://github.com/ngtanphuc/home-credit-risk/tree/main/src/models) (GBDT model families), [`src/data/clean.py`](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/data/clean.py) (Data cleaning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_ingestion["CSV ingestion<br/>[load.py]"]
  node_cleaning["Data cleaning<br/>[clean.py]"]
  node_splits["Fixed data splits<br/>[splits.py]"]
end

subgraph group_features["Feature engineering"]
  node_feature_builder["Feature builder<br/>[build.py]"]
  node_bureau_features["Bureau features<br/>[bureau.py]"]
  node_previous_features["Previous-loan features<br/>[previous.py]"]
  node_repayment_features["Repayment features<br/>[repayment.py]"]
end

subgraph group_experiments["Model experiments"]
  node_cv_runner["Cross-validation runner<br/>[runner.py]"]
  node_imbalance["Imbalance handling<br/>[imbalance.py]"]
  node_model_families["GBDT model families"]
  node_ensemble["Ensemble<br/>[ensemble.py]"]
  node_optuna_tuning["Optuna tuning<br/>[optuna_search.py]"]
  node_random_tuning["Random search<br/>[random_search.py]"]
end

subgraph group_evaluation["Scoring and evaluation"]
  node_calibration["Probability calibration<br/>[calibration.py]"]
  node_holdout["Final hold-out<br/>[holdout.py]"]
  node_metrics["Evaluation metrics<br/>[metrics.py]"]
  node_delong["DeLong comparison<br/>[delong.py]"]
end

subgraph group_explanation["Model explanation"]
  node_shap["SHAP analysis<br/>[shap_analysis.py]"]
  node_agreement["Model agreement<br/>[agreement.py]"]
end

node_researcher(("Researcher"))
node_home_credit_data["Home Credit data"]

node_researcher -->|"starts pipeline"| node_ingestion
node_home_credit_data -->|"provides CSVs"| node_ingestion
node_ingestion -->|"writes interim data"| node_cleaning
node_cleaning -->|"precedes split creation"| node_splits
node_cleaning -->|"precedes feature build"| node_feature_builder
node_feature_builder -.->|"builds feature groups"| node_bureau_features
node_feature_builder -.->|"builds feature groups"| node_previous_features
node_feature_builder -.->|"builds feature groups"| node_repayment_features
node_splits -->|"supplies fixed folds"| node_cv_runner
node_feature_builder -->|"supplies features"| node_cv_runner
node_cv_runner -->|"compares models"| node_model_families
node_cv_runner -->|"evaluates ensemble"| node_ensemble
node_cv_runner -->|"tests imbalance methods"| node_imbalance
node_optuna_tuning -.->|"tunes via experiments"| node_cv_runner
node_random_tuning -.->|"tunes via experiments"| node_cv_runner
node_model_families -->|"produces probabilities"| node_calibration
node_calibration -.->|"calibrates predictions"| node_holdout
node_holdout -->|"reports scores"| node_metrics
node_metrics -.->|"compares AUC"| node_delong
node_model_families -->|"explains predictions"| node_shap
node_model_families -->|"compares importance"| node_agreement

click node_ingestion "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/data/load.py"
click node_cleaning "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/data/clean.py"
click node_splits "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/cv/splits.py"
click node_feature_builder "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/build.py"
click node_bureau_features "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/bureau.py"
click node_previous_features "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/previous.py"
click node_repayment_features "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/repayment.py"
click node_cv_runner "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/cv/runner.py"
click node_imbalance "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/imbalance.py"
click node_model_families "https://github.com/ngtanphuc/home-credit-risk/tree/main/src/models"
click node_ensemble "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/models/ensemble.py"
click node_optuna_tuning "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/tuning/optuna_search.py"
click node_random_tuning "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/tuning/random_search.py"
click node_calibration "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/calibration.py"
click node_holdout "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/evaluation/holdout.py"
click node_metrics "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/evaluation/metrics.py"
click node_delong "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/evaluation/delong.py"
click node_shap "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/explain/shap_analysis.py"
click node_agreement "https://github.com/ngtanphuc/home-credit-risk/blob/main/src/explain/agreement.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_ingestion,node_cleaning,node_splits toneBlue
class node_feature_builder,node_bureau_features,node_previous_features,node_repayment_features toneAmber
class node_cv_runner,node_imbalance,node_model_families,node_ensemble,node_optuna_tuning,node_random_tuning toneMint
class node_calibration,node_holdout,node_metrics,node_delong toneRose
class node_shap,node_agreement,node_researcher,node_home_credit_data toneIndigo
```

## Components

### Data preparation

- [CSV ingestion](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/data/load.py): `src/data/load.py`
- [Data cleaning](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/data/clean.py): `src/data/clean.py`
- [Fixed data splits](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/cv/splits.py): `src/cv/splits.py`

### Feature engineering

- [Feature builder](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/build.py): `src/features/build.py`
- [Bureau features](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/bureau.py): `src/features/bureau.py`
- [Previous-loan features](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/previous.py): `src/features/previous.py`
- [Repayment features](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/features/repayment.py): `src/features/repayment.py`

### Model experiments

- [Cross-validation runner](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/cv/runner.py): `src/cv/runner.py`
- [Imbalance handling](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/imbalance.py): `src/imbalance.py`
- [GBDT model families](https://github.com/ngtanphuc/home-credit-risk/tree/main/src/models): `src/models`
- [Ensemble](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/models/ensemble.py): `src/models/ensemble.py`
- [Optuna tuning](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/tuning/optuna_search.py): `src/tuning/optuna_search.py`
- [Random search](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/tuning/random_search.py): `src/tuning/random_search.py`

### Scoring and evaluation

- [Probability calibration](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/calibration.py): `src/calibration.py`
- [Final hold-out](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/evaluation/holdout.py): `src/evaluation/holdout.py`
- [Evaluation metrics](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/evaluation/metrics.py): `src/evaluation/metrics.py`
- [DeLong comparison](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/evaluation/delong.py): `src/evaluation/delong.py`

### Model explanation

- [SHAP analysis](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/explain/shap_analysis.py): `src/explain/shap_analysis.py`
- [Model agreement](https://github.com/ngtanphuc/home-credit-risk/blob/main/src/explain/agreement.py): `src/explain/agreement.py`

### Other components

- **Researcher**
- **Home Credit data**

## Connections

- Researcher → CSV ingestion: starts pipeline (evidence: `README.md`)
- Home Credit data → CSV ingestion: provides CSVs (evidence: `README.md`)
- CSV ingestion → Data cleaning: writes interim data (evidence: `README.md`)
- Data cleaning → Fixed data splits: precedes split creation (evidence: `README.md`)
- Data cleaning → Feature builder: precedes feature build (evidence: `README.md`)
- Feature builder → Bureau features: builds feature groups
- Feature builder → Previous-loan features: builds feature groups
- Feature builder → Repayment features: builds feature groups
- Fixed data splits → Cross-validation runner: supplies fixed folds (evidence: `README.md`)
- Feature builder → Cross-validation runner: supplies features (evidence: `README.md`)
- Cross-validation runner → GBDT model families: compares models (evidence: `README.md`)
- Cross-validation runner → Ensemble: evaluates ensemble (evidence: `README.md`)
- Cross-validation runner → Imbalance handling: tests imbalance methods (evidence: `README.md`)
- Optuna tuning → Cross-validation runner: tunes via experiments
- Random search → Cross-validation runner: tunes via experiments
- GBDT model families → Probability calibration: produces probabilities (evidence: `README.md`)
- Probability calibration → Final hold-out: calibrates predictions
- Final hold-out → Evaluation metrics: reports scores (evidence: `README.md`)
- Evaluation metrics → DeLong comparison: compares AUC
- GBDT model families → SHAP analysis: explains predictions (evidence: `README.md`)
- GBDT model families → Model agreement: compares importance (evidence: `README.md`)
