# carlierrudy/scoring_resiliation architecture

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

- Interactive diagram: https://gitdiagram.com/carlierrudy/scoring_resiliation
- Repository: https://github.com/carlierrudy/scoring_resiliation

## Overview

This is a Streamlit application for estimating auto-insurance policy cancellation risk. An advisor enters a client profile or uploads a portfolio; the app scores it with a saved scikit-learn pipeline, applies a configurable alert threshold, and presents risk and feature-importance information or a downloadable scored CSV. The separate training script prepares data, compares and evaluates models, then saves the pipeline and metadata consumed by the app. The README also describes a notebook for step-by-step exploration. Some app and training code was not excerpted, so links for documented capabilities cite the README.

Main entry points: [`app.py`](https://github.com/carlierrudy/scoring_resiliation/blob/main/app.py) (Client profile and settings), [`models/pipeline_resiliation.pkl`](https://github.com/carlierrudy/scoring_resiliation/blob/main/models/pipeline_resiliation.pkl) (Scoring pipeline), [`train_model.py`](https://github.com/carlierrudy/scoring_resiliation/blob/main/train_model.py) (Prepare and train), [`data`](https://github.com/carlierrudy/scoring_resiliation/tree/main/data) (Source dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data"]
  node_source_data["Source dataset"]
end

subgraph group_model["Model lifecycle"]
  node_training["Prepare and train<br/>[train_model.py]"]
  node_model_files["Model and metadata"]
end

subgraph group_app["Scoring application"]
  node_profile["Client profile and settings<br/>[app.py]"]
  node_pipeline["Scoring pipeline"]
  node_individual["Individual risk result<br/>[app.py]"]
  node_importance["Feature importance<br/>[app.py]"]
  node_batch["Batch scoring and export<br/>[app.py]"]
end

subgraph group_analysis["Exploration"]
  node_exploration["Step-by-step exploration<br/>[tp_final.ipynb]"]
end

node_advisor(("Insurance advisor"))
node_portfolio["Client portfolio"]

node_training -->|"reads and prepares"| node_source_data
node_training -->|"saves model and metadata"| node_model_files
node_exploration -.->|"explores data"| node_source_data
node_advisor -->|"enters profile"| node_profile
node_profile -->|"loads assets"| node_model_files
node_profile -->|"requests prediction"| node_pipeline
node_pipeline -->|"returns risk score"| node_individual
node_individual -->|"shows influential variables"| node_importance
node_advisor -->|"uploads CSV"| node_portfolio
node_portfolio -->|"provides client rows"| node_batch
node_batch -->|"scores each row"| node_pipeline
node_batch -->|"offers scored CSV"| node_advisor

click node_source_data "https://github.com/carlierrudy/scoring_resiliation/tree/main/data"
click node_training "https://github.com/carlierrudy/scoring_resiliation/blob/main/train_model.py"
click node_model_files "https://github.com/carlierrudy/scoring_resiliation/tree/main/models"
click node_exploration "https://github.com/carlierrudy/scoring_resiliation/blob/main/notebooks/tp_final.ipynb"
click node_profile "https://github.com/carlierrudy/scoring_resiliation/blob/main/app.py"
click node_pipeline "https://github.com/carlierrudy/scoring_resiliation/blob/main/models/pipeline_resiliation.pkl"
click node_individual "https://github.com/carlierrudy/scoring_resiliation/blob/main/app.py"
click node_importance "https://github.com/carlierrudy/scoring_resiliation/blob/main/app.py"
click node_batch "https://github.com/carlierrudy/scoring_resiliation/blob/main/app.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_source_data,node_portfolio toneBlue
class node_training,node_model_files toneAmber
class node_profile,node_pipeline,node_individual,node_importance,node_batch toneMint
class node_exploration toneRose
class node_advisor toneIndigo
```

## Components

### Data

- [Source dataset](https://github.com/carlierrudy/scoring_resiliation/tree/main/data): `data`

### Model lifecycle

- [Prepare and train](https://github.com/carlierrudy/scoring_resiliation/blob/main/train_model.py): `train_model.py`
- [Model and metadata](https://github.com/carlierrudy/scoring_resiliation/tree/main/models): `models`

### Scoring application

- [Client profile and settings](https://github.com/carlierrudy/scoring_resiliation/blob/main/app.py): `app.py`
- [Scoring pipeline](https://github.com/carlierrudy/scoring_resiliation/blob/main/models/pipeline_resiliation.pkl): `models/pipeline_resiliation.pkl`
- [Individual risk result](https://github.com/carlierrudy/scoring_resiliation/blob/main/app.py): `app.py`
- [Feature importance](https://github.com/carlierrudy/scoring_resiliation/blob/main/app.py): `app.py`
- [Batch scoring and export](https://github.com/carlierrudy/scoring_resiliation/blob/main/app.py): `app.py`

### Exploration

- [Step-by-step exploration](https://github.com/carlierrudy/scoring_resiliation/blob/main/notebooks/tp_final.ipynb): `notebooks/tp_final.ipynb`

### Other components

- **Insurance advisor**
- **Client portfolio**

## Connections

- Prepare and train → Source dataset: reads and prepares (evidence: `train_model.py`)
- Prepare and train → Model and metadata: saves model and metadata (evidence: `train_model.py`)
- Step-by-step exploration → Source dataset: explores data (evidence: `README.md`)
- Insurance advisor → Client profile and settings: enters profile (evidence: `README.md`)
- Client profile and settings → Model and metadata: loads assets (evidence: `app.py`)
- Client profile and settings → Scoring pipeline: requests prediction (evidence: `README.md`)
- Scoring pipeline → Individual risk result: returns risk score (evidence: `README.md`)
- Individual risk result → Feature importance: shows influential variables (evidence: `README.md`)
- Insurance advisor → Client portfolio: uploads CSV (evidence: `README.md`)
- Client portfolio → Batch scoring and export: provides client rows (evidence: `app.py`)
- Batch scoring and export → Scoring pipeline: scores each row (evidence: `app.py`)
- Batch scoring and export → Insurance advisor: offers scored CSV (evidence: `README.md`)
