# shivammitra/customer-churn-model architecture

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

- Interactive diagram: https://gitdiagram.com/shivammitra/customer-churn-model
- Repository: https://github.com/shivammitra/customer-churn-model

## Overview

#### Purpose and execution model
This is a lightweight, notebook-driven customer churn-risk classification demo. The sole implementation entry point is `Churn Probability (Random Forest ) Model.ipynb`; it runs the full workflow interactively, from dataset acquisition through evaluation and an example prediction. There is no packaged service, CLI, or deployed inference endpoint.

#### Data acquisition boundary
The notebook obtains the Telco Customer Churn dataset through the external IBM Skills Network `skillsnetwork` helper rather than a versioned dataset stored in the repository. The model target is categorical `CHURNRISK` with Low, Medium, and High classes. This external download is the principal reproducibility and availability boundary.
- `Churn Probability (Random Forest ) Model.ipynb`

#### Exploration and feature preparation
The notebook first profiles the raw tabular data, audits missingness, and inspects churn-class distribution. It then separates numerical and categorical features into preprocessing paths:
- numerical columns: imputation followed by standard scaling;
- categorical columns: imputation followed by one-hot encoding.
This creates model-ready feature matrices while preserving a consistent transformation process for training and single-record scoring.
- `Churn Probability (Random Forest ) Model.ipynb`

#### Dataset partitioning
Prepared data is split 80/20 into training and test sets with stratification on churn risk. Stratification is the key control that preserves class representation between fit and evaluation datasets, especially for the three-level target.
- `Churn Probability (Random Forest ) Model.ipynb`

#### Model training
The central model is scikit-learn’s `RandomForestClassifier`, configured with 100 trees and `random_state=42`. The forest is the baseline predictive component and consumes the transformed mixed-type tabular features. The fixed seed supports repeatable model behavior given stable source data and library versions.
- `Churn Probability (Random Forest ) Model.ipynb`

#### Evaluation and interpretation
The test-set prediction flow produces overall accuracy and a full per-class precision, recall, and F1 classification report. The notebook additionally renders feature importance, providing a model-level interpretation layer; reported prominent drivers include trading-value, income, login-recency, and gains features.
- `Churn Probability (Random Forest ) Model.ipynb`

#### Persistence and inference demonstration
The notebook includes a placeholder `joblib` persistence step for serializing the trained random forest, but it must be enabled to create a reusable artifact. A final single-customer prediction demonstration represents the inference path. For production use, the fitted preprocessing state and model should be persisted and loaded together; otherwise one-hot feature alignment and scaling can diverge from training.
- `Churn Probability (Random Forest ) Model.ipynb`

Main entry points: [`Churn Probability (Random Forest ) Model.ipynb`](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb) (Random forest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_notebook["Interactive Notebook"]
  node_raw_dataset[("Telco churn data<br/>tabular dataset")]
  node_exploration["Data profiling<br/>notebook stage"]
  node_feature_split["Feature routing<br/>preprocessing stage"]
  node_numeric_pipeline["Numeric pipeline<br/>sklearn transformer"]
  node_categorical_pipeline["Categorical pipeline<br/>sklearn transformer"]
  node_prepared_features["Model-ready features<br/>feature matrix"]
  node_stratified_split["80/20 stratified split<br/>dataset partition"]
  node_random_forest{{"Random forest<br/>RandomForestClassifier"}}
  node_evaluation["Test evaluation<br/>evaluation stage"]
  node_feature_importance["Feature importance<br/>interpretation output"]
  node_single_customer["Single-customer scoring<br/>inference demonstration"]
  node_joblib_artifact["Optional joblib artifact<br/>serialized model"]
end

node_ibm_skillsnetwork[("IBM Skills Network<br/>external data source")]

node_ibm_skillsnetwork -->|"downloads"| node_raw_dataset
node_raw_dataset -->|"profiles"| node_exploration
node_raw_dataset -->|"routes features"| node_feature_split
node_feature_split -->|"numerical columns"| node_numeric_pipeline
node_feature_split -->|"categorical columns"| node_categorical_pipeline
node_numeric_pipeline -->|"transforms"| node_prepared_features
node_categorical_pipeline -->|"encodes"| node_prepared_features
node_prepared_features -->|"splits with target"| node_stratified_split
node_stratified_split -->|"training set"| node_random_forest
node_random_forest -->|"test predictions"| node_evaluation
node_random_forest -->|"importance scores"| node_feature_importance
node_random_forest -->|"predicts risk"| node_single_customer
node_random_forest -.->|"optional serialization"| node_joblib_artifact

click node_raw_dataset "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_exploration "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_feature_split "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_numeric_pipeline "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_categorical_pipeline "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_prepared_features "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_stratified_split "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_random_forest "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_evaluation "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_feature_importance "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_single_customer "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb"
click node_joblib_artifact "https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.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_raw_dataset,node_exploration,node_feature_split,node_numeric_pipeline,node_categorical_pipeline,node_prepared_features,node_stratified_split,node_random_forest,node_evaluation,node_feature_importance,node_single_customer,node_joblib_artifact toneBlue
class node_ibm_skillsnetwork toneNeutral
```

## Components

### Interactive Notebook

The sole implementation and execution entry point.

- [Telco churn data](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): tabular dataset · Contains the three-class CHURNRISK target. · `Churn Probability (Random Forest ) Model.ipynb`
- [Data profiling](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): notebook stage · Audits schema, missingness, and class distribution. · `Churn Probability (Random Forest ) Model.ipynb`
- [Feature routing](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): preprocessing stage · Separates numerical and categorical columns. · `Churn Probability (Random Forest ) Model.ipynb`
- [Numeric pipeline](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): sklearn transformer · Imputes then standard-scales numerical features. · `Churn Probability (Random Forest ) Model.ipynb`
- [Categorical pipeline](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): sklearn transformer · Imputes then one-hot encodes categorical features. · `Churn Probability (Random Forest ) Model.ipynb`
- [Model-ready features](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): feature matrix · Combined transformed mixed-type features. · `Churn Probability (Random Forest ) Model.ipynb`
- [80/20 stratified split](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): dataset partition · Preserves Low, Medium, and High class representation. · `Churn Probability (Random Forest ) Model.ipynb`
- [Random forest](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): RandomForestClassifier · 100 trees with random_state=42. · `Churn Probability (Random Forest ) Model.ipynb`
- [Test evaluation](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): evaluation stage · Computes accuracy and per-class precision, recall, and F1. · `Churn Probability (Random Forest ) Model.ipynb`
- [Feature importance](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): interpretation output · Shows model-level driver importance. · `Churn Probability (Random Forest ) Model.ipynb`
- [Single-customer scoring](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): inference demonstration · Applies the workflow to one customer record. · `Churn Probability (Random Forest ) Model.ipynb`
- [Optional joblib artifact](https://github.com/shivammitra/customer-churn-model/blob/main/Churn%20Probability%20(Random%20Forest%20)%20Model.ipynb): serialized model · Placeholder persistence step that must be enabled. · `Churn Probability (Random Forest ) Model.ipynb`

### Other components

- **IBM Skills Network**: external data source · Downloads the Telco Customer Churn dataset.

## Connections

- IBM Skills Network → Telco churn data: downloads
- Telco churn data → Data profiling: profiles
- Telco churn data → Feature routing: routes features
- Feature routing → Numeric pipeline: numerical columns
- Feature routing → Categorical pipeline: categorical columns
- Numeric pipeline → Model-ready features: transforms
- Categorical pipeline → Model-ready features: encodes
- Model-ready features → 80/20 stratified split: splits with target
- 80/20 stratified split → Random forest: training set
- Random forest → Test evaluation: test predictions
- Random forest → Feature importance: importance scores
- Random forest → Single-customer scoring: predicts risk
- Random forest → Optional joblib artifact: optional serialization
