# javvajivarun/credit-risk-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/javvajivarun/credit-risk-prediction
- Repository: https://github.com/javvajivarun/credit-risk-prediction

## Overview

This is a single-script credit-risk analysis pipeline for predicting loan defaults while optimizing expected loss and measuring age-group fairness. The principal workflow loads or generates data, preprocesses it, trains a reweighted random forest, selects a loss-sensitive threshold, calibrates thresholds by age group, and visualizes results. The graph preserves these documented stages and major capabilities. Source excerpts confirm several implementation details, but omit parts of the script; stage-to-stage links therefore rely on the README rather than claims about unseen calls.

Main entry points: [`complete_pipeline.py`](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py) (Default probabilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_pipeline["Pipeline runner"]
  node_data_source[("Credit dataset")]
  node_data_loading["Data loading"]
  node_preprocessing["Preprocessing"]
  node_train_split["Train-test split"]
end

subgraph group_model["Risk modeling"]
  node_sample_weights["Sample reweighting"]
  node_random_forest["Random forest"]
  node_probabilities["Default probabilities"]
end

subgraph group_decision["Decision and fairness"]
  node_loss_sweep["Expected-loss sweep"]
  node_fairness_report["Age-group analysis"]
  node_group_thresholds["Group thresholds"]
end

subgraph group_results["Results"]
  node_visualization["Visualization"]
  node_reports["Metrics and results"]
end

node_user(("Analyst"))

node_user -->|"runs"| node_pipeline
node_data_source -->|"provides data"| node_data_loading
node_pipeline -->|"starts"| node_data_loading
node_data_loading -->|"then preprocesses"| node_preprocessing
node_preprocessing -->|"then splits"| node_train_split
node_train_split -->|"then reweights"| node_sample_weights
node_sample_weights -->|"trains"| node_random_forest
node_random_forest -->|"estimates risk"| node_probabilities
node_probabilities -->|"sweeps thresholds"| node_loss_sweep
node_probabilities -->|"measures fairness"| node_fairness_report
node_loss_sweep -->|"informs calibration"| node_group_thresholds
node_fairness_report -->|"guides fairness fix"| node_group_thresholds
node_loss_sweep -->|"plots losses"| node_visualization
node_group_thresholds -->|"plots fairness"| node_visualization
node_visualization -->|"presents results"| node_reports

click node_pipeline "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_data_loading "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_preprocessing "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_train_split "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_sample_weights "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_random_forest "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_probabilities "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_loss_sweep "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_fairness_report "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_group_thresholds "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_visualization "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py"
click node_reports "https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.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_pipeline,node_data_source,node_data_loading,node_preprocessing,node_train_split toneBlue
class node_sample_weights,node_random_forest,node_probabilities toneAmber
class node_loss_sweep,node_fairness_report,node_group_thresholds toneMint
class node_visualization,node_reports toneRose
class node_user toneIndigo
```

## Components

### Data preparation

- [Pipeline runner](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`
- **Credit dataset**
- [Data loading](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`
- [Preprocessing](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`
- [Train-test split](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`

### Risk modeling

- [Sample reweighting](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`
- [Random forest](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`
- [Default probabilities](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`

### Decision and fairness

- [Expected-loss sweep](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`
- [Age-group analysis](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`
- [Group thresholds](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`

### Results

- [Visualization](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`
- [Metrics and results](https://github.com/javvajivarun/credit-risk-prediction/blob/main/complete_pipeline.py): `complete_pipeline.py`

### Other components

- **Analyst**

## Connections

- Analyst → Pipeline runner: runs (evidence: `README.md`)
- Credit dataset → Data loading: provides data (evidence: `README.md`)
- Pipeline runner → Data loading: starts (evidence: `README.md`)
- Data loading → Preprocessing: then preprocesses (evidence: `README.md`)
- Preprocessing → Train-test split: then splits (evidence: `README.md`)
- Train-test split → Sample reweighting: then reweights (evidence: `README.md`)
- Sample reweighting → Random forest: trains (evidence: `README.md`)
- Random forest → Default probabilities: estimates risk (evidence: `README.md`)
- Default probabilities → Expected-loss sweep: sweeps thresholds (evidence: `README.md`)
- Default probabilities → Age-group analysis: measures fairness (evidence: `README.md`)
- Expected-loss sweep → Group thresholds: informs calibration (evidence: `README.md`)
- Age-group analysis → Group thresholds: guides fairness fix (evidence: `README.md`)
- Expected-loss sweep → Visualization: plots losses (evidence: `README.md`)
- Group thresholds → Visualization: plots fairness (evidence: `README.md`)
- Visualization → Metrics and results: presents results (evidence: `README.md`)
