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.
- 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
The target label is y (subscription outcome). The classes are imbalanced (more “no” than “yes”), so metrics beyond accuracy are used.
The script:
- Converts
yes/nofields (e.g.,default,housing,loan, andy) into1/0 - Splits into train/test sets using stratification
- Scales features using StandardScaler
The following feature sets are evaluated:
- All features
- Variance threshold (removes very low-variance features)
- Correlation filter (removes highly correlated features)
- Combined (variance + correlation)
- Uses
class_weight='balanced'to account for class imbalance.
- 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]
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
Running the script generates:
model_comparison_results.csvmodel_comparison_results.xlsx
python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activatepip install -U numpy pandas matplotlib seaborn openpyxl scikit-learn tensorflow keraspython feed-forward-ANN.pyfeed-forward-ANN.py— pipeline: pre-processing, feature selection, training, evaluation, and exporting resultsas1-bank.csv— dataset used by the scriptmodel_comparison_results.csv— exported comparison tablemodel_comparison_results.xlsx— exported comparison table (Excel)