How mukund-1/churn-modelling works
Project type and purpose
• This is a single‐page Streamlit web application for real‐time customer churn prediction at a bank.
• It loads a pre‐trained TensorFlow deep learning model and associated preprocessing artifacts (encoders and scaler) to predict churn probability based on user‐provided inputs.
File structure
• Top‐level files:
• app.py – Streamlit app (serving logic + UI)
• model.h5 – pre‐trained TensorFlow model
• onehot_encoder_geo.pkl, label_encoder_gender.pkl, scaler.pkl – preprocessing artifacts
• Churn_Modelling.csv – raw dataset used during training
• experiments.ipynb, hyperparametertuningann.ipynb, prediction.ipynb – Jupyter notebooks for data exploration, model tuning, prediction experiments
• requirements.txt – Python dependencies list
• There is no separate “frontend” and “backend” directory; the Streamlit script combines both layers.
Extract key insights from the README
• Inputs: Geography, Gender, Age, Balance, Credit Score, Estimated Salary, Tenure, Number of Products, Credit Card flag, Active Membership flag
• Preprocessing: label encoding, one‐hot encoding, feature scaling
• Prediction threshold: 0.5
• Run command: streamlit run app.py
Main components
a. User Interface (UI)
– Streamlit web front end (dropdowns, sliders, input fields)
– Hosted by Streamlit server
b. Serving/Inference Pipeline
– app.py (requests → preprocessing → model inference → response)
– Preprocessing module
• LabelEncoder (gender)
• OneHotEncoder (geography)
• Scaler
– Model module
• TensorFlow model.h5
c. Data Artifacts & Repositories
– model repository (model.h5, *.pkl files)
– raw data CSV (Churn_Modelling.csv) used in training
– Jupyter notebooks (experiments & hyperparameter tuning)
d. Dependencies & Environment
– Python runtime
– Libraries: streamlit, tensorflow, scikit‐learn, pandas, numpy, etc.
Relationships and interactions
• User interacts with Streamlit UI → UI sends input payload to app.py
• app.py loads preprocessing artifacts → transforms raw inputs into model‐ready feature vector
• Preprocessed data flows into TensorFlow model → churn probability returned
• app.py applies decision threshold → output (“likely to churn” / “unlikely to churn”) displayed back on the UI
• The raw dataset and notebooks feed into an offline training pipeline (not part of the runtime app) that produces the model and artifacts.
Important architectural patterns/design principles
• Separation of concerns:
• UI layer (Streamlit)
• Preprocessing layer (encoders + scaler)
• Model inference layer (TensorFlow)
• Immutable artifacts: model.h5 and pickles are read‐only in production
• Lightweight one‐service architecture: all components run in a single Python process under Streamlit