# karunya-475/churn-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/karunya-475/churn-prediction
- Repository: https://github.com/karunya-475/churn-prediction

## Overview

#### Purpose and entry point
This is a notebook-centric machine-learning analysis for predicting bank credit-card customer churn (`Attrition_Flag`). The primary executable artifact is `Churn Prediction.ipynb`; it reads and analyzes the local source dataset `Churn Prediction.csv`. There is no packaged service, CLI, deployment artifact, or automated pipeline in the repository.

#### Source data boundary
`Churn Prediction.csv` is the system-of-record input: 10,127 customer records with demographics, account characteristics, and transaction behavior. Its target is the categorical `Attrition_Flag` field, distinguishing retained from churned customers. Data ingestion, integrity validation, and downstream transformations are expected to occur within `Churn Prediction.ipynb`.

#### Inspection and exploratory-analysis stage
The notebook first validates schema, dimensions, missing values, and duplicates, then performs EDA across categorical and numerical features. This establishes distribution, class-balance, skewness, outlier, and target-association context before model training.
- `Churn Prediction.ipynb`
- `Churn Prediction.csv`

#### Feature preparation boundary
Raw customer fields must be converted into model-ready inputs: target encoding (`Existing Customer`/`Attrited Customer`), categorical encoding, and numerical standardization. The intended separation is between predictors and `Attrition_Flag`; scaling is specifically relevant to models such as logistic regression.
- `Churn Prediction.ipynb`

#### Classification-model stage
The notebook is intended to train and compare several supervised binary classifiers: logistic regression as baseline; decision tree and random forest; and boosting approaches such as XGBoost or gradient boosting. Model selection is based on comparative evaluation rather than a declared production champion.
- `Churn Prediction.ipynb`

#### Evaluation and decision flow
Prepared records flow from preprocessing into each classifier, producing churn predictions/scores evaluated with precision, recall, F1, and ROC-AUC. Recall is materially important because churn is expected to be the minority class and missed churners are costly. Findings identify transaction volume/value and engagement features as key churn signals.
- `Churn Prediction.ipynb`

#### Runtime and future integration
The current runtime is an interactive Jupyter notebook with a local CSV dependency and likely Python ML libraries (not dependency-pinned in the repository). No external APIs, databases, cloud infrastructure, or model registry are present. Planned—but not implemented—boundaries include scikit-learn pipeline automation, imbalance handling (SMOTE/undersampling), hyperparameter search, and serving through Flask/FastAPI with a Streamlit dashboard.

Main entry points: [`Churn Prediction.ipynb`](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb) (Model-ready inputs), [`Churn Prediction.csv`](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.csv) (Churn Prediction.csv)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_notebook["Interactive notebook"]
  node_notebook_runtime["Churn Prediction.ipynb<br/>Jupyter notebook"]
  node_ingestion_validation["Ingestion &amp; validation<br/>notebook stage"]
  node_eda["Exploratory analysis<br/>notebook stage"]
  node_feature_preparation["Feature preparation<br/>notebook stage"]
  node_model_ready_data["Model-ready inputs<br/>prepared dataset"]
  node_comparative_evaluation["Comparative evaluation<br/>evaluation stage"]
  node_findings["Churn signal findings<br/>analysis output"]
end

subgraph group_models["Classifier comparison"]
  node_logistic_regression["Logistic regression<br/>baseline classifier"]
  node_decision_tree["Decision tree<br/>classifier"]
  node_random_forest["Random forest<br/>classifier"]
  node_boosting["Boosting models<br/>classifier family"]
  node_predictions_scores["Churn predictions &amp; scores<br/>model output"]
end

node_source_csv[("Churn Prediction.csv<br/>source dataset")]

node_source_csv -->|"read locally"| node_notebook_runtime
node_notebook_runtime -->|"executes"| node_ingestion_validation
node_ingestion_validation -->|"validated records"| node_eda
node_ingestion_validation -->|"validated fields"| node_feature_preparation
node_eda -->|"informs preparation"| node_feature_preparation
node_feature_preparation -->|"encoded and scaled"| node_model_ready_data
node_model_ready_data -->|"train"| node_logistic_regression
node_model_ready_data -->|"train"| node_decision_tree
node_model_ready_data -->|"train"| node_random_forest
node_model_ready_data -->|"train"| node_boosting
node_logistic_regression -->|"predict"| node_predictions_scores
node_decision_tree -->|"predict"| node_predictions_scores
node_random_forest -->|"predict"| node_predictions_scores
node_boosting -->|"predict"| node_predictions_scores
node_predictions_scores -->|"metrics"| node_comparative_evaluation
node_comparative_evaluation -->|"selects insights"| node_findings

click node_source_csv "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.csv"
click node_notebook_runtime "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_ingestion_validation "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_eda "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_feature_preparation "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_model_ready_data "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_logistic_regression "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_decision_tree "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_random_forest "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_boosting "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_predictions_scores "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_comparative_evaluation "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"
click node_findings "https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb"

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_notebook_runtime,node_ingestion_validation,node_eda,node_feature_preparation,node_model_ready_data,node_comparative_evaluation,node_findings toneBlue
class node_logistic_regression,node_decision_tree,node_random_forest,node_boosting,node_predictions_scores toneAmber
class node_source_csv toneNeutral
```

## Components

### Interactive notebook

All analysis, preparation, training, and evaluation run in one notebook.

- [Churn Prediction.ipynb](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): Jupyter notebook · Primary executable artifact. · `Churn Prediction.ipynb`
- [Ingestion & validation](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): notebook stage · Checks schema, dimensions, missing values, and duplicates. · `Churn Prediction.ipynb`
- [Exploratory analysis](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): notebook stage · Examines distributions, imbalance, outliers, and target associations. · `Churn Prediction.ipynb`
- [Feature preparation](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): notebook stage · Encodes target and categorical fields; standardizes numerical features. · `Churn Prediction.ipynb`
- [Model-ready inputs](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): prepared dataset · Predictors separated from encoded Attrition_Flag. · `Churn Prediction.ipynb`
- [Comparative evaluation](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): evaluation stage · Compares precision, recall, F1, and ROC-AUC; recall is important for missed churn. · `Churn Prediction.ipynb`
- [Churn signal findings](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): analysis output · Highlights transaction volume, value, and engagement as key signals. · `Churn Prediction.ipynb`

### Classifier comparison

- [Logistic regression](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): baseline classifier · `Churn Prediction.ipynb`
- [Decision tree](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): classifier · `Churn Prediction.ipynb`
- [Random forest](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): classifier · `Churn Prediction.ipynb`
- [Boosting models](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): classifier family · XGBoost or gradient boosting comparison candidates. · `Churn Prediction.ipynb`
- [Churn predictions & scores](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.ipynb): model output · `Churn Prediction.ipynb`

### Other components

- [Churn Prediction.csv](https://github.com/karunya-475/churn-prediction/blob/main/Churn%20Prediction.csv): source dataset · System-of-record customer data with Attrition_Flag target. · `Churn Prediction.csv`

## Connections

- Churn Prediction.csv → Churn Prediction.ipynb: read locally
- Churn Prediction.ipynb → Ingestion & validation: executes
- Ingestion & validation → Exploratory analysis: validated records
- Ingestion & validation → Feature preparation: validated fields
- Exploratory analysis → Feature preparation: informs preparation
- Feature preparation → Model-ready inputs: encoded and scaled
- Model-ready inputs → Logistic regression: train
- Model-ready inputs → Decision tree: train
- Model-ready inputs → Random forest: train
- Model-ready inputs → Boosting models: train
- Logistic regression → Churn predictions & scores: predict
- Decision tree → Churn predictions & scores: predict
- Random forest → Churn predictions & scores: predict
- Boosting models → Churn predictions & scores: predict
- Churn predictions & scores → Comparative evaluation: metrics
- Comparative evaluation → Churn signal findings: selects insights
