October 2018
Intermediate to advanced
172 pages
4h 6m
English
In this section, you will learn how to implement the decision tree regressor in scikit-learn. The first step is to import the data, and create the features and target variables. We can do this using the following code:
import pandas as pd#Reading in the datasetdf = pd.read_csv('fraud_prediction.csv')#Dropping the indexdf = df.drop(['Unnamed: 0'], axis = 1)#Creating the features features = df.drop('amount', axis = 1).valuestarget = df['amount'].values
Note how, in the case of regression, the target variable is the amount, and not the isFraud column.
Next, we split the data into training and test sets, and build the decision tree regressor, as shown in the following code:
from sklearn.model_selection ...
Read now
Unlock full access