🏦 Bank Customer Churn Prediction (ANN | Keras)

A lightweight Keras ANN for bank customer churn prediction (Exited: 0 = stay, 1 = churn).
This Hugging Face repo hosts the trained model plus preprocessing artifacts used by a Streamlit inference app.

Training → Model → Inference

What’s in this repo

  • artifacts/model.h5 (Keras model)
  • artifacts/scaler.pkl (StandardScaler)
  • artifacts/label_encoder_gender.pkl (LabelEncoder for Gender)
  • artifacts/onehot_encoder_geo.pkl (OneHotEncoder for Geography)
  • artifacts/schema.json (feature order + mappings)
  • Churn_Modelling.csv (dataset copy used in training)

Inputs (feature order)

The model expects 12 features in this exact order (see artifacts/schema.json): CreditScore, Gender, Age, Tenure, Balance, NumOfProducts, HasCrCard, IsActiveMember, EstimatedSalary, Geography_France, Geography_Germany, Geography_Spain

Preprocessing (same as training/inference app):

  • Gender: label-encoded (Female: 0, Male: 1)
  • Geography: one-hot encoded into the 3 geography columns
  • All final features are scaled using StandardScaler (from scaler.pkl)

Output

  • Returns a churn probability in [0, 1].
  • schema.json stores a default decision threshold of 0.5. (The Streamlit demo app uses 0.35 by default to be more sensitive to churn.)

Quickstart (load artifacts)

import tensorflow as tf, pickle, json
from huggingface_hub import hf_hub_download

REPO_ID = "ash001/bank-churn-ann"

model = tf.keras.models.load_model(hf_hub_download(REPO_ID, "artifacts/model.h5"), compile=False)
scaler = pickle.load(open(hf_hub_download(REPO_ID, "artifacts/scaler.pkl"), "rb"))
le_gender = pickle.load(open(hf_hub_download(REPO_ID, "artifacts/label_encoder_gender.pkl"), "rb"))
ohe_geo = pickle.load(open(hf_hub_download(REPO_ID, "artifacts/onehot_encoder_geo.pkl"), "rb"))
schema = json.load(open(hf_hub_download(REPO_ID, "artifacts/schema.json"), "r"))

For an end-to-end preprocessing + prediction example, refer to the Streamlit inference file: pages/01_Bank_Churn_Prediction.py.

Notes / limitations

  • Intended for learning/demo; may not generalize to other banks/time periods without retraining and monitoring.
  • Contains .pkl artifacts—only unpickle files you trust.

license: apache-2.0

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support