Bank Marketing#
Data from the phone-call marketing campaigns of a Portuguese bank. Each sample is a client, and the task is to predict whether the client subscribed a term deposit. It is a good dataset for practising with categorical features and with unbalanced classes.
Overview#
Loader |
|
Task |
Classification |
Samples |
45211 |
Features |
16 |
Targets |
2 classes: |
Missing values |
None |
License |
CC BY 4.0 |
Features#
Nine features are categorical and stored as integer codes: job, marital,
education, default, housing, loan, contact, month and poutcome.
The names of the categories, in the order of the codes, are in data.info.categorical, and
data.categorical_features gives the columns. The other seven features are whole numbers:
age, balance (average yearly balance in euros), day (day of the month of the last
contact), duration (seconds), campaign, pdays and previous.
The features describe three things: the client (age to loan), the last contact of the
current campaign (contact to duration) and the earlier campaigns (campaign to
poutcome).
Some entries of job, education, contact and poutcome are unknown in the source.
They are stored as the category unknown, so the dataset has no NaN values. pdays is
-1 for clients who were not contacted in an earlier campaign, and the value is kept as it is.
Warning
duration is known only after the call, and the call ends with the answer of the
client. The source advises to use it for benchmarks only and to drop it for a realistic
predictive model.
Target#
y is 0 if the client did not subscribe a term deposit (39922 clients) and 1 if the client
did (5289). The classes are unbalanced, so accuracy alone is a poor measure of a model.
Source and citation#
Source: UCI Machine Learning Repository
Obtained from: UCI Machine Learning Repository, dataset 222, downloaded with the ucimlrepo package: all 45211 examples with 16 inputs (the bank-full version). The ucimlrepo version is recorded in the file.
Creators: S. Moro, P. Rita, P. Cortez
Please cite the dataset as:
Moro, S., Rita, P., & Cortez, P. (2014). Bank Marketing [Dataset]. UCI Machine Learning Repository. https://doi.org/10.24432/C5K306
See also:
Moro, S., Cortez, P., & Rita, P. (2014). A data-driven approach to predict the success of bank telemarketing. Decision Support Systems, 62, 22-31.
License#
CC BY 4.0, as stated by the source. The license was checked at the source on 2026-10-23. See License and citation.
Changes made#
Converted to the NumPy NPZ format. Numeric features are stored as float64 and the target as int64 labels.
Categorical features are stored as integer codes, in the order of the category names listed for each feature. The target is 0 for no and 1 for yes.
Entries of job, education, contact and poutcome that the UCI release marks as missing are stored as the category unknown, which the data description of the source lists for these features. No NaN values are stored.
The column that UCI calls day_of_week is named day, because the source describes it as the day of the month of the last contact.
Note
The duration of the last call is only known after the call, and the call ends with the answer. The source advises to use duration for benchmarks only and to drop it for a realistic predictive model.
Note
pdays is -1 for clients who were not contacted in a previous campaign. The value is kept as it is in the source.
Note
The classes are not balanced: far fewer clients subscribed than not.
Example#
>>> import numpy as np
>>> from pyml_datasets import load_bank_marketing
>>> data = load_bank_marketing()
>>> data.X.shape
(45211, 16)
>>> data.has_missing
False
>>> data.categorical_features
(1, 2, 3, 4, 6, 7, 8, 10, 15)
>>> data.info.categorical["education"]
('primary', 'secondary', 'tertiary', 'unknown')
>>> data.target_names
('no', 'yes')
>>> np.bincount(data.y)
array([39922, 5289])