← Back to Projects Deep Learning

Customer Churn Prediction with ANN (Classification)

A bank-customer churn classifier built with an ANN after encoding mixed categorical and numerical features into one training pipeline.

PythonTensorFlowscikit-learnANN
Question Can a small feed-forward neural network learn churn patterns from a mixture of demographic and account variables?
Focus Neural networks · Categorical encoding · Binary classification
Outcome An ANN churn-classification pipeline with encoded features, scaling and confusion-matrix evaluation.

The problem

This project developed a binary classification model to predict bank customer churn using an Artificial Neural Network (ANN). I built a deep learning solution to identify customers likely to leave the bank based on their demographic and account information, enabling proactive retention strategies.

Question

Can a small feed-forward neural network learn churn patterns from a mixture of demographic and account variables?

Approach

Rather than presenting the project as a notebook dump, this case study focuses on the decisions that shaped the analysis.

  1. Load & inspect data: Loaded customer banking dataset with demographic and account features, selected relevant features (columns [:, 3:-1]) as input variables and extracted churn status as target binary variable loc[] .
  2. Data preprocessing Analysis: Applied Label Encoding to convert Gender column to numerical format, Implemented One-Hot Encoding for Geography column to handle multiple categories and used ColumnTransformer to apply different encodings to specific columns
  3. Model Architecture: Built Sequential ANN with three layers: two hidden layers (6 units each, ReLU activation ) and output layer (1 unit, sigmoid activation ), compiled with Adam optimizer and binary crossentropy loss for binary classification and trained for 100 epochs with batch size of 32
  4. Model Evaluation: Generated predictions on test set with 0.5 probability threshold, created confusion matrix to analyze true/false positives and negatives and calculated accuracy score for overall model performance assessment

Key implementation decision

Make heterogeneous tabular data model-ready before tuning the network

The hardest part was not the neural-network syntax; it was constructing a consistent numerical feature matrix. Label encoding, one-hot encoding and standardisation were separated so each variable type was handled deliberately.

ct = ColumnTransformer(
    transformers=[("encoder", OneHotEncoder(), [1])],
    remainder="passthrough"
)
X = np.array(ct.fit_transform(X))

sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)

ann = tf.keras.models.Sequential([
    tf.keras.layers.Dense(6, activation="relu"),
    tf.keras.layers.Dense(6, activation="relu"),
    tf.keras.layers.Dense(1, activation="sigmoid"),
])
Why this matters

Churn data mixes categories such as geography with financial measurements on very different scales. The project became an exercise in building a clean preprocessing path before asking the network to learn anything useful.

Results & evidence

The figures below are the project evidence I would show first. The full implementation remains available through the GitHub link at the top of the page.

What challenged me

The main challenge was handling mixed categorical and numerical data types efficiently. Initially, I struggled with applying different encoding methods to different columns simultaneously. After experimenting with various approaches, I discovered ColumnTransformer, which allowed me to apply One-Hot Encoding to geography while preserving other numerical features, streamlining the preprocessing pipeline significantly.

What I learned

  • The preprocessing pipeline was as important as the ANN architecture because the raw data mixed categories and continuous financial variables.
  • Standardisation helped make the optimisation problem better behaved for the neural network.
  • Churn evaluation should focus on how well likely churners are identified, not only on aggregate accuracy.

What I would improve next

  • Compare the ANN with simpler tabular baselines such as logistic regression and tree ensembles.
  • Use precision, recall and class-specific error analysis to assess how well likely churners are detected.
  • Move preprocessing into a reusable pipeline so training and single-customer inference cannot drift apart.
Full implementation: use the GitHub link in the project header for the complete notebook/code rather than expanding the case study into a full source listing.