October 2018
Intermediate to advanced
172 pages
4h 6m
English
In this section, we will learn how we can implement the gradient boosted regressor in scikit-learn. The first step, as usual, is to import the dataset, define the features and target arrays, and split the data into training and test sets. This can be done using the following code:
import pandas as pdfrom sklearn.model_selection import train_test_split#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#Splitting the data into training and test setsX_train, X_test, y_train, y_test = train_test_split(features, target, test_size ...Read now
Unlock full access