6. Building Your Own Program
Activity 6.01: Performing the Preparation and Creation Stages for the Bank Marketing Dataset
Solution:
Note
To ensure the reproducibility of the results available at https://packt.live/2RpIhn9, make sure that you use a random_state
of 0
when splitting the datasets and a random_state
of 2
when training the models.
- Open a Jupyter Notebook and import all the required elements:
import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.model_selection import train_test_split from sklearn.tree import DecisionTreeClassifier from sklearn.neural_network import MLPClassifier from sklearn.metrics import precision_score
- Load the dataset into the notebook. Make sure that you load the one that was edited previously, named
bank-full-dataset.csv
, which is also available at https://packt.live/2wnJyny:data = pd.read_csv("bank-full-dataset.csv") data.head(10)
The output is as follows: