Datasets
The bank marketing file
Before a telephone call is placed, how likely is this client to subscribe to a term deposit?
The file, and the notebooks that read it
data
folder beside the notebook. Every notebook reads data/bank.csv
and is run from its own folder.What this data answers
It answers who will say yes if contacted, as contacts happened historically. It does not answer who would say yes because of the call, because no client was deliberately left uncalled for comparison.
Dataset overview
| Question | Before a telephone call is placed, how likely is this client to subscribe to a term deposit? |
| Observation | One recorded contact with one client, from a campaign run between May 2008 and November 2010. |
| Target | subscribed. 1 if the client subscribed to a term deposit, 0 otherwise. |
| Inputs | age, job, marital, education, default, housing, loan, contact, month, day_of_week, campaign, pdays, previous, poutcome, emp_var_rate, cons_price_idx, cons_conf_idx, euribor3m, nr_employed |
| Size | 41,188 rows and 22 columns. |
| Held back | duration, recorded only after the call ends, so it cannot inform the decision to call. |
How the rows are divided
A stratified random split, so each group holds the same share of subscribers, 11.27 per cent. A later difference in scores therefore cannot be explained by one group simply containing more subscribers.
| Group | Rows | What you may do with it |
|---|---|---|
fitting | 24,712 | estimate the model |
checking | 8,238 | compare finished models, once each |
final | 8,238 | opened once, after every choice is frozen |
Data dictionary
Every column in bank.csv. The
fourth column is the one to read before modelling: a variable that is not
known when the prediction is needed cannot be used, however well it
predicts.
| Column | Type | What it means | When is this known? |
|---|---|---|---|
split | category | fitting, checking, or final. | Added for this course. Not part of the published data. |
age | whole number | Client age in years. | Known before the call. |
job | category | Occupation. 12 levels including unknown. | Known before the call. |
marital | category | Marital status. | Known before the call. |
education | category | Highest education recorded. | Known before the call. |
default | category | Has credit in default: yes, no, or unknown. | Known before the call. |
housing | category | Has a housing loan. | Known before the call. |
loan | category | Has a personal loan. | Known before the call. |
contact | category | Contact channel: cellular or telephone. | Chosen before the call is placed. |
month | category | Month of the contact. | Known when the call is scheduled. |
day_of_week | category | Weekday of the contact. | Known when the call is scheduled. |
duration | whole number, seconds | Call length in seconds. | ONLY AFTER THE CALL ENDS. It cannot inform the decision to call, so every model on this course excludes it. |
campaign | whole number | Contacts made to this client during this campaign, including this one. | Known before the call. |
pdays | whole number | Days since the client was last contacted. 999 means never contacted before. | Known before the call. Treat 999 as a category, not a long gap. |
previous | whole number | Contacts made to this client before this campaign. | Known before the call. |
poutcome | category | Outcome of the previous campaign. | Known before the call. |
emp_var_rate | number | Employment variation rate, quarterly. | Describes the month, not the client. Shared by every contact that month. |
cons_price_idx | number | Consumer price index, monthly. | Describes the month, not the client. |
cons_conf_idx | number | Consumer confidence index, monthly. | Describes the month, not the client. |
euribor3m | number | Three-month euribor rate, daily. | Describes the market, not the client. |
nr_employed | number | Number of employees, quarterly. | Describes the economy, not the client. |
subscribed | 0 or 1 (target) | 1 if the client subscribed to a term deposit. | The final outcome. Known only after the call has been made and answered. |
Source and preparation
The source is UCI Machine Learning Repository, Bank Marketing (bank-additional-full), a Portuguese bank's campaigns, May 2008 to November 2010, released under CC BY 4.0. S. Moro, P. Cortez and P. Rita (2014), 'A data-driven approach to predict the success of bank telemarketing', Decision Support Systems 62. DOI 10.24432/C5K306.
All 41,188 rows are kept and no row is filtered. Three changes were made to the published file, all of them cosmetic or explanatory.
| Step | Rows left | Why |
|---|---|---|
| Published rows | 41,188 | every recorded contact is used |
| Column names | 41,188 | full stops became underscores, so emp.var.rate is emp_var_rate |
| Outcome column | 41,188 | the yes/no column y became a 0 or 1 column named subscribed |
| Separator | 41,188 | the original is semicolon-separated; this copy is an ordinary comma CSV |
4,640 of the 41,188 contacts ended in a subscription, so the base rate is 11.27 per cent. That number is the benchmark every model has to beat, and a rule that says no to everybody is already 88.74 per cent accurate.
What this data does not establish
- Call duration correlates with the outcome at 0.41 and is unusable. A highly predictive variable can still be an invalid input; the test is whether it exists at the moment the decision is made.
- In pdays, 999 is not a long gap. It is a different category, and it covers 96.3 per cent of rows.
- The five economic columns describe the month, not the client. Every contact in the same month shares them.
- The file records only clients the bank chose to call, so it cannot identify who subscribes because of a call.
Where it is used
- Day 1b. Day 1b uses it for baselines, the confusion matrix, thresholds and both kinds of leakage.
- Day 2. Day 2 fits logistic regression on it, scores it with log loss, and prices the cut-off.
- Day 3. Day 3 compares trees, forests and boosting on it, and stress-tests it on later calls.