Skip to content

Repository files navigation

Feedforward Neural Network

This repository trains and evaluates a feedforward artificial neural network (FFNN) to predict whether a customer will subscribe to a term deposit using bank marketing campaign data. A logistic regression model is also included as a baseline.

What this project does

  • Loads the dataset (as1-bank.csv)
  • Applies basic pre-processing (encoding and scaling)
  • Tests different feature selection options
  • Trains multiple FFNN architectures (different layer sizes)
  • Evaluates performance using metrics suitable for imbalanced classification
  • Exports results to CSV and Excel

Dataset

The target label is y (subscription outcome). The classes are imbalanced (more “no” than “yes”), so metrics beyond accuracy are used.

Pre-processing

The script:

  • Converts yes/no fields (e.g., default, housing, loan, and y) into 1/0
  • Splits into train/test sets using stratification
  • Scales features using StandardScaler

Feature selection options

The following feature sets are evaluated:

  • All features
  • Variance threshold (removes very low-variance features)
  • Correlation filter (removes highly correlated features)
  • Combined (variance + correlation)

Models

Baseline: Logistic Regression

  • Uses class_weight='balanced' to account for class imbalance.

Feedforward Neural Networks (TensorFlow/Keras)

  • Dense networks with ReLU hidden layers and a Sigmoid output layer
  • Uses class weights to reduce bias towards the majority class
  • Uses early stopping to help prevent overfitting

Architectures tested include:

  • Single hidden layer: [32], [64]
  • Two hidden layers: [64, 32], [128, 64]
  • Three hidden layers: [128, 64, 32], [256, 128, 64]

Evaluation

Metrics reported include:

  • Accuracy, Precision, Recall, F1-score
  • MCC (Matthews Correlation Coefficient)
  • Balanced Accuracy, G-Mean
  • AUPRC (Area Under the Precision–Recall Curve)
  • Confusion matrices for top models

Outputs

Running the script generates:

  • model_comparison_results.csv
  • model_comparison_results.xlsx

How to run

1) (Recommended) Create a virtual environment

python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate

2) Install dependencies

pip install -U numpy pandas matplotlib seaborn openpyxl scikit-learn tensorflow keras

3) Run the script

python feed-forward-ANN.py

Repository contents

  • feed-forward-ANN.py — pipeline: pre-processing, feature selection, training, evaluation, and exporting results
  • as1-bank.csv — dataset used by the script
  • model_comparison_results.csv — exported comparison table
  • model_comparison_results.xlsx — exported comparison table (Excel)

Happy to provide my report on this repo if requested, reach out to oscar.a-r@hotmail.com

About

A feed-forward artificial neural network I created as part of a machine learning module during my MSc. This was on the UCI Bank Marketing dataset (preprocessed / encoded version), with 13 input features + 1 target.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages