Introduction

In this article we build a machine learning model with the goal of predicting which customers of a bank are interested in opening a term deposit account. For this purpose we compare seven classification algorithms, with emphasis on Boosting models (XGBoost and LightGBM). The data come from the “UCI Machine Learning Repository” and specifically from the Bank Marketing dataset.

Before the analysis, let us define a few basic concepts.

What is a term deposit?

It is a type of bank account in which the customer commits not to make a withdrawal for a predefined period of time (e.g. one year). In exchange, the bank offers higher interest rates compared with ordinary savings accounts.

Indicatively:

  • Piraeus Bank offers double the interest rate on its term-deposit accounts.
  • Eurobank offers zero interest on savings accounts, 0.01%–0.35% on savings-plan accounts, and 0.1%–1% on term deposits, depending on the programme and the size of the deposit.
  • According to a recent report by the Bank of Greece, term-deposit interest rates range between 1.2% and 1.4%, versus just 0.03% for standard household accounts.

The suitable profile for these products generally concerns people with a significant savings balance and without heavy financial obligations (loans, overdue debts).

Prerequisites

Importing libraries

For this analysis we will need standard R libraries for importing the data, through the {readr} package, and formatting it with the {dplyr} package. The {kableExtra} package is a significant addition for printing the results in table form. An important part is that of data visualisation. Initially I used the {ggplot2} package to create charts, which is limiting for a website since ggplot2 produces static charts. So for my articles I use the {highcharter} package, which enables interactive charts that are friendly to all screen types. Finally, this analysis aims to categorise the bank’s customers by their interest in a banking product, so the use of the {tidymodels} package is essential.

Importing data

Once we have loaded the necessary libraries, we need to import our data. There are several versions of the same data, a larger one and a more compact version; their difference lies only in the number of observations. For this article I will choose the more compact form, since fitting Boosting models is particularly time-consuming compared with building simpler classification models (e.g. Logistic Regression, k-Nearest Neighbours).

Data preview

Below is a small sample of the dataset (the first 6 observations), so that we understand its structure and the type of the variables.

Table 1 Data preview The first 6 of the bank's 4,521 clients
ID Age age Job job Marital marital Education education Default default Balance balance Housing housing Loan loan Contact contact Day day Month month Duration duration Campaign campaign pdays pdays Previous previous Poutcome poutcome Deposit y
1 30 Unemployed Married Primary No 1,787 No No Mobile 19 October 79 1 −1 0 Unknown No
2 33 Services Married Secondary No 4,789 Yes Yes Mobile 11 May 220 1 339 4 Failure No
3 35 Management Single Tertiary No 1,350 Yes No Mobile 16 April 185 1 330 1 Failure No
4 30 Management Married Tertiary No 1,476 Yes Yes Unknown 3 June 199 4 −1 0 Unknown No
5 59 Blue Collar Married Secondary No 0 Yes No Unknown 5 May 226 1 −1 0 Unknown No
6 35 Management Single Tertiary No 747 No No Mobile 23 February 141 2 176 3 Failure No
Source: UCI Machine Learning Repository (Bank Marketing)

Before doing any analysis it is good to determine the type of the data we have available. In general, variables can be classified as follows:

  • Quantitative: Discrete or Continuous
  • Qualitative: Categorical or Ordinal
Table 2 The dataset variables 17 variables for each client: demographics, banking details, campaign details and the client's response
Variable Type Description
Age Quantitative (continuous) Age of the individual
Job Qualitative (categorical) Individual's field of employment
Marital Qualitative (categorical) Marital status
Education Qualitative (ordinal) Highest level of education
Default Qualitative (categorical) Has defaulted on credit obligations?
Balance Quantitative (continuous) Average annual account balance (in €)
Housing Qualitative (categorical) Has a housing loan?
Loan Qualitative (categorical) Has a personal loan?
Contact Qualitative (categorical) Means of contact
Day Quantitative Day of the month of the most recent contact
Month Qualitative (ordinal) Month of most recent contact
Duration Quantitative (continuous) Duration (in seconds) of the last contact
Campaign Quantitative Number of contacts made to an individual
pdays Quantitative Number of days since the last contact
previous Quantitative Number of times the client was contacted
poutcome Qualitative (nominal) Outcome of the previous marketing campaign
Deposit Qualitative (nominal) Did the client open a term deposit?
Source: UCI Machine Learning Repository (Bank Marketing)

Our sample consists of 17 variables (columns), of which 7 are quantitative and the remaining 10 qualitative. As for the qualitative variables, 8 of them are categorical and only two are ordinal (promotion month and level of education).

Defining functions

Ok, we saw some basic details of my data and its structure. Can I now start my analysis?

It depends. If we want a quick analysis in order to extract a specific result, it is probably fine. Of course, most of the time a more careful study design is required. A common mistake I too have fallen into in the past is the risk of repeating certain procedures. To avoid writing the same things many times, it is essential to write some functions.

Consequently, we define two functions. First, univariateQualitativePlot, which is used to create pie charts and bar charts for the qualitative variables. Similarly, we will also define the univariateQuantitativePlot function for building bar charts for our quantitative variables. Both functions build charts using the {highcharter} package.

Descriptive Analysis

Missing values

In the given dataset there are a total of 0 missing values. This is, of course, a rare, ideal case. Otherwise, we would have to fill the empty values using some estimation method.

Univariate analysis

Next it is important to study our variables, their values and their distributions. This is an important part in order to understand the sample and take further parameters into account when building the model.

As for the field of employment, the sample shows a significant participation of people in jobs that are probably combined with higher studies and consequently higher earnings, such as executives, administrative staff, entrepreneurs, etc. About 40% of the bank’s customers are employed in “blue-collar” jobs, which are most often combined with a reduced willingness to commit capital. Finally, in the bank’s clientele there is a share of around 10% concerning population groups for whom, for various reasons, it is not advantageous to open such an account, such as the unemployed, students, as well as pensioners who in turn will need to cover emergency healthcare needs.

Figure 1 Clients' field of employment Number of clients by job, out of 4,521
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Frequency
Management 969
Blue Collar 946
Technician 768
Administrative 478
Services 417
Retired 230
Self-Employed 183
Entrepreneur 168
Unemployed 128
Housemaid 112
Student 84
Unknown 38

Another available piece of information is marital status, which may be linked to increased needs and household expenses. In general, the interpretation of this indicator is not clear in advance. In any case, in the sample under examination we have around 60% of individuals who are married, a quarter of the customers are single, and the rest are divorced.

Figure 2 Clients' marital status Number and share (%) of the 4,521 clients
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Frequency Share (%)
Married 2,797 61.9
Single 1,196 26.5
Divorced 528 11.7

An indicator that, at least intuitively, may be among the most important is the customer’s highest level of education. It is reasonable that someone with a higher level of studies is able to work in jobs that require specialisation. In this particular dataset, only 30% have a university education.

Figure 3 Clients' highest level of education Number of clients by level of education, out of 4,521
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Frequency
Secondary 2,306
Tertiary 1,350
Primary 678
Unknown 187

Beyond studies, the individual’s obligations also play an important role. These can be distinguished through three variables:

  • whether the customer has debts
  • whether the customer has taken out a housing loan
  • whether the customer has taken out a personal consumer loan

It is obvious that if someone has non-performing debts, the last thing they will think about is saving. In the sample, only 76 people, corresponding to 1.6% of customers, fall into this category.

Figure 4 Clients with defaulted credit Number and share (%) of the 4,521 clients who have or have not defaulted on their credit
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Frequency Share (%)
No 4,445 98.3
Yes 76 1.7

In addition, a significant share of the bank’s customers already have substantial obligations, both in the short and long term. More than half have taken out a housing loan. What may be a more significant factor for refusal is consumer loans, which are notorious for their high interest rates. In our case, about 15% have taken out a consumer loan, which is a slightly optimistic figure.

Table 3 Clients' loans Number and share (%) of clients with a housing and with a personal loan
(a) Housing loan
Has housing loan? Frequency Share (%)
Yes 2,559 56.6
No 1,962 43.4
(b) Personal loan
Has personal loan? Frequency Share (%)
No 3,830 84.7
Yes 691 15.3
Source: UCI Machine Learning Repository (Bank Marketing)

Another piece of information provided is the means of contact with the customer. More than half (64%) have declared a mobile phone as their means of contact.

Figure 5 Contact method with the clients Number and share (%) of clients by contact method
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Frequency Share (%)
Mobile 2,896 64.1
Unknown 1,324 29.3
Landline 301 6.7

Another interesting variable is the last month in which a customer was contacted. Most of the last contacts appear to have been made during the summer months. Of course, this figure needs care in its interpretation.

Figure 6 Month of the last contact Number of clients by month of the last contact in the campaign
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Frequency
May 1,398
July 706
August 633
June 531
November 389
April 293
February 222
January 148
October 80
September 52
March 49
December 20

According to the data and its description, the bank had also run similar campaigns in previous years. As a result of the previous campaigns, we had 129 interested parties for closed accounts, while the status of many is unknown.

Figure 7 Outcome of the previous campaign Number and share (%) of clients by outcome of the previous campaign
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Frequency Share (%)
Unknown 3,705 82.0
Failure 490 10.8
Other 197 4.4
Success 129 2.9

The bank’s depositors are mainly of younger age and the vast majority under 60 years old. The histogram appears to have a bell shape resembling the normal distribution, but there is a slight positive skew.

Figure 8 Age distribution of the clients Number of clients by age, in 2-year groups
Note. Median age: 39 years.
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Age Frequency
18–20 7
20–22 16
22–24 44
24–26 121
26–28 197
28–30 247
30–32 423
32–34 417
34–36 368
36–38 320
38–40 272
40–42 276
42–44 220
44–46 231
46–48 222
48–50 213
50–52 177
52–54 165
54–56 164
56–58 176
58–60 118
60–62 23
62–64 15
64–66 15
66–68 7
68–70 13
70–72 10
72–74 9
74–76 8
76–78 9
78–80 10
80–82 1
82–84 5
84–86 1
86–88 1

Closely linked to the customer’s profile is the size of their bank balance. The distribution of deposits is strongly right-skewed: the vast majority is concentrated around low balances (a median of just €444), with a long tail of a few customers with particularly high deposits. There is even a small share with a negative balance.

Figure 9 Distribution of the account balance Number of clients by average yearly balance, in groups of €2,000
Note. Median balance: €444. Range: -€3,313 to €71,188.
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Account balance (€) Frequency
-4000–-2000 2
-2000–0 721
0–2000 2,911
2000–4000 454
4000–6000 200
6000–8000 86
8000–10000 55
10000–12000 24
12000–14000 20
14000–16000 13
16000–18000 11
18000–20000 4
20000–22000 4
22000–24000 6
24000–26000 1
26000–28000 7
28000–30000 0
30000–32000 0
32000–34000 0
34000–36000 0
36000–38000 0
38000–40000 0
40000–42000 0
42000–44000 1
44000–46000 0
46000–48000 0
48000–50000 0
50000–52000 0
52000–54000 0
54000–56000 0
56000–58000 0
58000–60000 0
60000–62000 0
62000–64000 0
64000–66000 0
66000–68000 0
68000–70000 0
70000–72000 1

Another element is the duration of the call. Intuitively, if the call lasts very briefly it is estimated that the customer is not interested. Otherwise, increased interaction between the caller on behalf of the company and the customer probably indicates increased interest in the banking product.

Figure 10 Duration of the last call Number of clients by call duration, in 50-second groups
Note. Mean duration: ~4.4 minutes. Median: ~3 minutes.
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Call duration (seconds) Frequency
0–50 380
50–100 690
100–150 761
150–200 599
200–250 493
250–300 335
300–350 243
350–400 185
400–450 141
450–500 100
500–550 98
550–600 74
600–650 73
650–700 61
700–750 47
750–800 44
800–850 24
850–900 23
900–950 17
950–1000 26
1000–1050 20
1050–1100 9
1100–1150 11
1150–1200 12
1200–1250 7
1250–1300 6
1300–1350 2
1350–1400 3
1400–1450 5
1450–1500 7
1500–1550 7
1550–1600 2
1600–1650 1
1650–1700 2
1700–1750 4
1750–1800 0
1800–1850 1
1850–1900 1
1900–1950 0
1950–2000 2
2000–2050 1
2050–2100 1
2100–2150 0
2150–2200 0
2200–2250 0
2250–2300 0
2300–2350 0
2350–2400 0
2400–2450 0
2450–2500 1
2500–2550 0
2550–2600 0
2600–2650 0
2650–2700 0
2700–2750 0
2750–2800 1
2800–2850 0
2850–2900 0
2900–2950 0
2950–3000 0
3000–3050 1

Finally, it is worth seeing how many times each customer was contacted in the context of the current campaign. Most received one or two calls, while a smaller part was contacted repeatedly, something that rarely pays off.

Figure 11 Contacts with each client in the current campaign Number of clients by number of contacts (1 to 8 or more)
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Contacts (#) Frequency
1 1,734
2 1,264
3 558
4 325
5 167
6 155
7 75
8+ 243

To close the univariate analysis, let us also look at the response variable itself: how many, that is, finally opened a term deposit. As expected, the data is strongly imbalanced, with only ~11% of customers responding positively. This imbalance will particularly concern us at the modelling stage.

Figure 12 How many opened a term deposit? Number and share (%) of clients who did or did not open a term deposit in the current campaign
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Frequency Share (%)
No 4,000 88.5
Yes 521 11.5

Bivariate analysis

In the previous sub-section, some basic descriptive details were examined per variable. In this case it would be additionally beneficial to compare the previous variables with the response variable (that is, with the desire to open a term-deposit account).

An important comparison is the customer’s field of employment against their final decision. The data indicate the lowest proportional demand among people with manual work, while pensioners are those with the highest.

The above results were perhaps expected to some extent. The case of pensioners is interesting: while we initially assumed that they are not a suitable audience because of possible emergency needs, the data show that they respond positively at a higher rate. This can be explained by the fact that many pensioners already have a stable income without significant new obligations.

Figure 13 Response to the current campaign by job Share (%) of clients in each job who did or did not open a term deposit
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category No (%) Yes (%)
Retired 76.5 23.5
Student 77.4 22.6
Unknown 81.6 18.4
Management 86.5 13.5
Housemaid 87.5 12.5
Administrative 87.9 12.1
Self-Employed 89.1 10.9
Technician 89.2 10.8
Unemployed 89.8 10.2
Services 90.9 9.1
Entrepreneur 91.1 8.9
Blue Collar 92.7 7.3
Table 4 Campaign success rates by job The values of Figure 13, sorted by the share of «Yes»
Job No (%) Yes (%)
Retired 76.5 23.5
Student 77.4 22.6
Unknown 81.6 18.4
Management 86.5 13.5
Housemaid 87.5 12.5
Administrative 87.9 12.1
Self-Employed 89.1 10.9
Technician 89.2 10.8
Unemployed 89.8 10.2
Services 90.9 9.1
Entrepreneur 91.1 8.9
Blue Collar 92.7 7.3
Note. Row percentages: each job adds up to 100%.
Source: UCI Machine Learning Repository (Bank Marketing)

But there are also variables under examination for which the answer is not obvious, such as marital status. In the figure, the significantly higher proportional participation of people who are on their own (either as single or divorced) is examined.

Figure 14 Response to the current campaign by marital status Share (%) of clients of each marital status who did or did not open a term deposit
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category No (%) Yes (%)
Divorced 85.4 14.6
Single 86.0 14.0
Married 90.1 9.9

A summary of the above can also be made with a flow diagram. The first column indicates the distribution across marital statuses combined with the educational background, and we end up at the third column, which is the customer’s final answer.

Figure 15 Marital status → Education → Outcome How many clients flow from each marital status to each level of education and to their response to the campaign
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
From To Clients
Divorced Primary 79
Divorced Secondary 270
Divorced Tertiary 155
Divorced Unknown 24
Married Primary 526
Married Secondary 1,427
Married Tertiary 727
Married Unknown 117
Single Primary 73
Single Secondary 609
Single Tertiary 468
Single Unknown 46
Primary No 614
Primary Yes 64
Secondary No 2,061
Secondary Yes 245
Tertiary No 1,157
Tertiary Yes 193
Unknown No 168
Unknown Yes 19

I considered it important to compare the difference between the previous and the current campaign. Initially, the bank retains a large part of the trust of the previous users of the service, since 64% of those who had agreed to open a term deposit do so again with the new campaign. The crucial figure in this bivariate analysis is the extent to which it persuaded the customers who had refused the service. This share approaches 13%, which is a fairly satisfactory performance.

Figure 16 Previous vs current campaign How many clients end up at each current response, compared with their previous one
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
From To Clients
Failure No 427
Failure Yes 63
Other No 159
Other Yes 38
Success No 46
Success Yes 83
Unknown No 3,368
Unknown Yes 337

Model Building

In R there are two widespread ways of composing models, caret and tidymodels. On the one hand, the caret package is quite easy to use. On the other hand, tidymodels is an “all-in-one” solution, since it is a meta-package that tries to provide a complete solution; however, there is less documentation because it was created recently.

Splitting the dataset

The first step is to split the original dataset. In this particular analysis we use a three-way split:

  • Training set (bank_train): used to train all the models and for cross-validation.
  • Validation set (bank_val): a small part of the training set that we keep sealed exclusively for selecting the optimal classification threshold of the Stack Ensemble.
  • Test set (bank_test): used only for the final evaluation; we do not touch it at any other stage.
Table 5 Data subsets and their purpose How the 4,521 clients were split into training, validation and final testing
Subset Observations Purpose
Full set 4,521 -
bank_trainval 3,390 Training + validation
bank_test 1,131 Final evaluation only
bank_train 2,712 Model training & cross-validation
bank_val 678 Stack Ensemble threshold selection
Source: UCI Machine Learning Repository (Bank Marketing)

bank_val contains about 678 observations, enough to give a reliable estimate of the threshold, without removing a significant part of the training data.

Data preprocessing

Of course, building the models is not such an easy matter. Between splitting the dataset and composing the models comes data preprocessing. Fortunately, the {tidymodels} package offers ready-made commands. There are also other packages that address common problems in our dataset. For example, in our data most customers are expected not to want to open a term deposit. Our data is characterised as imbalanced when the variable I am trying to predict has a large difference between categories (90% do not want / 10%). In this case we use the step_smote() command from the {themis} package.

It is worth noting that the duration variable (call duration) was deliberately removed from the models. The reason is that the value of this variable becomes known only after the call is completed, that is, after the event we are trying to predict. If we included it, we would create a data-leakage problem. In addition, the poutcome variable was also removed, as it concerns previous campaigns for which there is insufficient data for the vast majority of customers.

Cross-validation

Ok, is it time to build our model?

Not so fast. Theoretically we could continue, however the recommended method is not to simply take two parts, since further evaluation is largely based on how the split was made.

Cross-validation is a technique in which the training set is divided into k equal subsets (folds). At each iteration, one fold is used as the evaluation set and the remaining k-1 as the training set. In our case, we used 5-fold cross-validation with stratification so that the ratio of interested / not-interested is maintained in each fold.

Building the model

Next, with the {parsnip} package we have the ability to define the characteristics of the various models. Seven different classification models were developed and compared: Logistic Regression, k-Nearest Neighbours (KNN), Random Forest, Naive Bayes, SVM, XGBoost and LightGBM.

Applying the models

Having defined the models and the corresponding workflows, we proceed to optimise their hyperparameters. For the simpler models we use grid search (tune_grid()). For the gradient boosting models (XGBoost and LightGBM), I choose Bayesian optimisation (tune_bayes()), which saves time compared with exhaustive search.

Beyond the individual evaluation of each model, we also apply a technique called stacking. The idea behind stacking is that instead of choosing a single model as the final one, we combine the predictions of several models into a meta-model. I use the {stacks} package:

A note on the Stack Ensemble threshold

Unlike the individual models (LightGBM, XGBoost, Logistic Regression) for which we can draw out-of-fold predictions from cross-validation, the Stack Ensemble does not have corresponding predictions. For this reason we created bank_val earlier, which is a subset of the training set that the model has not seen during training, and is used exclusively for selecting the threshold.

Threshold selection

Each model produces for each customer a probability of interest, not directly a decision. To move from the probability to the classification (“yes” / “no”) we need a threshold: if the probability exceeds this threshold, the customer is classified as interested.

The default value of 0.5 is rarely the optimal choice with imbalanced data; in our case only 11% of customers belong to the “yes” category. Instead, we choose the threshold that maximises F1, which balances the ability to detect interested customers (recall) with the reliability of the positive predictions (precision).

A common mistake is to find the threshold on the same test set used for the final evaluation. To avoid this, we follow a different approach depending on the model:

  • For the individual models we use the out-of-fold (OOF) predictions from cross-validation.
  • For the Stack Ensemble we use bank_val.

It is worth noting that the thresholds differ significantly between models. This does not mean that some model is “wrong”; each model simply calibrates its probabilities differently. What matters is that each threshold was found on data that the corresponding model had not used during training.

Table 6 Optimal threshold per model The probability cut-off that maximises F1 on the validation set (678 clients)
Model Threshold F1 (estimate)
Stack Ensemble (v1) 0.1035 0.396
Stack Ensemble (v2) 0.1341 0.396
LightGBM 0.2533 0.385
XGBoost 0.3195 0.370
Naive Bayes 0.7316 0.365
Random Forest 0.4146 0.362
Logistic Regression 0.5559 0.319
SVM 0.6287 0.309
Source: UCI Machine Learning Repository (Bank Marketing)

Results

Variable importance

From the variable-importance analysis of the LightGBM model, it emerges that the most decisive factors for predicting interest in a term deposit are the unknown means of contact (15.4%) and the existence of a housing loan (15.2%), followed by secondary education (10.2%) and the “married” marital status (9.5%). The contribution of the contact month is also notable, with May standing out as the most important (8.0%). These results largely agree with the findings of the descriptive analysis.

Figure 17 Variable importance The 10 variables with the highest importance (%) in the LightGBM model
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data
Category Importance (%) (%)
Unknown contact method 15.41
Housing loan 15.23
Secondary education 10.18
Married 9.50
Month: May 7.97
Month: August 3.56
Days since last contact 3.48
Job: Management 3.36
Number of contacts 2.94
Balance 2.81
Table 7 Variable importance The values of Figure 17, from highest to lowest
Variable Importance (%)
Unknown contact method 15.41
Housing loan 15.23
Secondary education 10.18
Married 9.50
Month: May 7.97
Month: August 3.56
Days since last contact 3.48
Job: Management 3.36
Number of contacts 2.94
Balance 2.81
Source: UCI Machine Learning Repository (Bank Marketing)

Model comparison

Before proceeding to the final evaluation, it is worth comparing graphically the predictive ability of the top models with the help of ROC curves (Receiver Operating Characteristic curves). The ROC curve depicts sensitivity against the false-positive rate, across all possible thresholds. The closer the curve is to the upper left corner, the better the overall predictive ability. From the diagram, the superiority of the combined models (Stack Ensemble) over the others is clearly evident.

Figure 18 ROC curves How well the 4 best models tell interested clients apart, on the test set
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data

1,001 rows: too many for a table on this page. Download the file for all the numbers.

With imbalanced data such as ours, the ROC curve can be overly optimistic. For this reason, we additionally examine the Precision–Recall curves, which focus exclusively on the category we are interested in (the interested customers). The dashed reference line corresponds to the performance of a model with no discriminative ability (equal to the frequency of the positive category, ~11.6%).

Figure 19 Precision-recall curves How reliable the models' positive predictions are, on the test set, where only 11% say yes
Source: UCI Machine Learning Repository (Bank Marketing)
Show the data

132 rows: too many for a table on this page. Download the file for all the numbers.

Overall, we observe that accuracy on its own is misleading. XGBoost, which shows the top accuracy value (88.4%), has essentially zero F1, since it detects no truly interested customer. This happens because accuracy mainly “rewards” the correct negative predictions, and in our imbalanced data, saying “no” to the vast majority is easy. F1 is the most honest criterion here, because it penalises false positives and false negatives equally. In terms of sensitivity, the combined models and Logistic Regression stand out, detecting about 50% of the truly interested; LightGBM, by contrast, sacrifices part of its sensitivity (≈39%) in favour of higher accuracy and positive predictive value among the strong models.

Table 8 Model comparison on the test set Accuracy, F1, sensitivity, specificity and precision, with each model's cut-off (threshold) from Table 6
Model Accuracy F1 Sensitivity Specificity Precision
LightGBM 0.866 0.402 0.389 0.928 0.415
Stack Ensemble (v2) 0.828 0.401 0.496 0.872 0.337
Stack Ensemble (v1) 0.809 0.379 0.504 0.849 0.304
SVM 0.794 0.340 0.458 0.838 0.270
Random Forest 0.822 0.337 0.389 0.879 0.297
Logistic Regression 0.758 0.332 0.519 0.789 0.244
Naive Bayes 0.869 0.178 0.122 0.967 0.327
XGBoost 0.884 — 0.000 1.000 —
Note. ▲ Highest value in the column.
— no value.
Source: UCI Machine Learning Repository (Bank Marketing)

Conclusions

This second table translates the statistical measures into business reality and highlights a different ranking. LightGBM appears as the most efficient choice per call: with just 123 calls it achieves a per-call success of 41.5%, that is, about 4 in 10 contacts pay off. If the resource being spent is the call centre’s time, this model respects that resource more. The price, however, is 80 lost interested parties: out of 131 it detected only 51.

If, on the contrary, the goal is to detect as many interested parties as possible, first place goes to Logistic Regression, which catches 68 out of 131 (the most of all models) but at a cost of 279 calls and a success rate of just 24.4%. The combined models follow very closely (Stack Ensemble v1: 66 interested, v2: 65), with significantly fewer calls. Among these high-recall options, Stack Ensemble v2 makes the fewest wrong approaches (128 versus 151 for v1, that is 23 fewer), so it is preferable when we want to bother as few uninterested people as possible.

The absolute surprise was the results of XGBoost, with zero correct predictions out of 131 truly positive cases, practically useless for our purpose. On the other side, Naive Bayes is interesting, being particularly economical (32.7% success with just 49 calls), although it detects only 16 interested parties.

Table 9 Business evaluation per model If the bank called only the clients each model suggests: right and wrong calls, missed clients and success per call, on the test set
Model True positives (TP) False positives (FP) Missed prospects (FN) Total calls Success per call (%)
LightGBM 51 72 80 123 41.5
Stack Ensemble (v2) 65 128 66 193 33.7
Naive Bayes 16 33 115 49 32.7
Stack Ensemble (v1) 66 151 65 217 30.4
Random Forest 51 121 80 172 29.7
SVM 60 162 71 222 27.0
Logistic Regression 68 211 63 279 24.4
XGBoost 0 0 131 0 —
Note. ▲ Highest value in the column.
— no value.
Source: UCI Machine Learning Repository (Bank Marketing)

From the above analysis it becomes clear that there is no “right” or best model, but rather the one that serves our purpose. If the bank’s goal were to detect as many interested parties as possible, then the answer leans towards Logistic Regression or the combined models. The goals could, however, be more conservative, for example, to expand the services but bother as few uninterested people as possible. In such a case Stack Ensemble v2 is ideal, since it makes the fewest wrong contacts among the high-recall models. Finally, if the priority is efficiency per call (that is, respecting the call centre’s time), the winner is clearly LightGBM.

In conclusion, the ideal model is not determined solely by the ideal parameters, but by the question itself and the purpose of our organisation.