October 2018
Intermediate to advanced
172 pages
4h 6m
English
In this section, you will learn how to implement the decision tree classifier in scikit-learn. We will work with the same fraud detection dataset. The first step is to load the dataset into the Jupyter Notebook. We can do this by using the following code:
import pandas as pddf = pd.read_csv('fraud_prediction.csv')
The next step is to split the data into training and test sets. We can do this using the following code:
#Creating the features features = df.drop('isFraud', axis = 1).valuestarget = df['isFraud'].valuesX_train, X_test, y_train, y_test = train_test_split(features, target, test_size = 0.3, random_state = 42, stratify = target)
We can now build the initial decision tree classifier ...
Read now
Unlock full access