# bhavesh2205/bank-customer-churn-prediction architecture

> Architecture diagram of the GitHub repository bhavesh2205/bank-customer-churn-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhavesh2205/bank-customer-churn-prediction
- Repository: https://github.com/bhavesh2205/bank-customer-churn-prediction

## Overview

##### Main Components
- Data Source: The raw data is provided via churn_data.csv. This is the base dataset containing customer records.
- Data Exploration & Preprocessing: Components include Exploratory Data Analysis (usually performed in notebook.ipynb), handling missing values/outliers, encoding categorical variables (with one-hot and label encoding), and scaling numerical features (as indicated in the README).
- Feature Engineering: A module that selects important features through correlation analysis and feature importance metrics.
- Model Training: This module represents the training of multiple models (e.g., Logistic Regression, Decision Trees, Random Forest, SVM, KNN, XGBoost, CatBoost). It includes handling data imbalance using SMOTE and possibly iterating over various models. The catboost_info directory indicates additional logging or configuration for CatBoost training.
- Model Evaluation: Where the performance metrics (Accuracy, Precision, Recall, F1-Score, ROC-AUC) are calculated to determine the best model. The README mentions that Random Forest was determined to be best.
- Model Persistence: This is the stage of saving the trained model objects using pickle (as seen in the pickle directory, which houses the random_forest.pkl, label_encoder.pkl, scaler.pkl).
- Deployment: Represented by app.py, which likely loads the pickled model(s) to expose a web application for making predictions. The README also notes hosting on the Render cloud platform.

##### Relationships and Interactions
- The output is then fed into Feature Engineering and subsequently to the Model Training Pipeline, which branches to multiple models.
- An evaluation component collects the results of various models. Feedback here can help select the final model (in this case, Random Forest).
- The chosen model is serialized (saved via pickle) and then loaded by the Deployment component (app.py).
- How external libraries (e.g., CatBoost, scikit-learn, SMOTE) interact as part of the training modules.

##### Architectural Patterns and Technologies
- Modular Design: Each step (Data Preprocessing, Feature Engineering, Model Training, Evaluation, and Deployment) is separated into independent parts.
- Tools & Technologies: Include technologies like Python (app.py, notebook.ipynb), scikit-learn, CatBoost (with its own log via catboost_info folder), pickle for model persistence, and the Render cloud platform for deployment.

- Data Source (churn_data.csv)
- Data Exploration/Preprocessing (processes performed in notebook.ipynb and possibly parts of app.py if integrated)
- Feature Engineering
- Model Training (with a branch indicating multiple models including CatBoost, Random Forest, etc.)
- Model Evaluation (highlight metrics calculation)
- Model Persistence (pickle saving of models and encoders)
- Deployment (app.py showing the API/web app)
- External Services: Render cloud deployment

## Diagram (Mermaid)

```mermaid
graph TD
    A["Data Ingestion"]:::data
    B["Data Exploration & Preprocessing"]:::processing
    C["Feature Engineering"]:::processing
    D["Model Training Pipeline (SMOTE & Multiple Algorithms)"]:::training
    D1["Logistic Regression"]:::training
    D2["Decision Trees"]:::training
    D3["Random Forest"]:::training
    D4["SVM"]:::training
    D5["KNN"]:::training
    D6["XGBoost"]:::training
    D7["CatBoost"]:::training
    Q["Trained Models Ensemble"]:::training
    E["Model Evaluation (Metrics: Accuracy,Precision,Recall,F1,ROC-AUC)"]:::evaluation
    F["Model Persistence (via pickle)"]:::deployment
    G["Deployment: Web Application"]:::deployment
    H["Render Cloud Deployment"]:::external

    A -->|"feeds"| B
    B -->|"outputs"| C
    C -->|"engineered features"| D
    D -->|"trains"| D1
    D -->|"trains"| D2
    D -->|"trains"| D3
    D -->|"trains"| D4
    D -->|"trains"| D5
    D -->|"trains"| D6
    D -->|"trains"| D7
    D1 --> Q
    D2 --> Q
    D3 --> Q
    D4 --> Q
    D5 --> Q
    D6 --> Q
    D7 --> Q
    Q -->|"evaluates"| E
    E -->|"saves model"| F
    F -->|"loads model"| G
    G -->|"hosted on"| H

    click A "https://github.com/bhavesh2205/bank-customer-churn-prediction/blob/main/churn_data.csv"
    click B "https://github.com/bhavesh2205/bank-customer-churn-prediction/blob/main/notebook.ipynb"
    click D7 "https://github.com/bhavesh2205/bank-customer-churn-prediction/tree/main/catboost_info"
    click F "https://github.com/bhavesh2205/bank-customer-churn-prediction/tree/main/pickle"
    click G "https://github.com/bhavesh2205/bank-customer-churn-prediction/blob/main/app.py"

    classDef data fill:#AED6F1,stroke:#2E86C1,stroke-width:2px;
    classDef processing fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef training fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
    classDef evaluation fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef deployment fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
```
