October 2018
Intermediate to advanced
172 pages
4h 6m
English
In this section, we will learn how we can implement the AdaBoost classifier in scikit-learn in order to predict if a transaction is fraudulent or not. As usual, the first step is to import the data and split it into training and testing sets.
This can be done with the following code:
#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('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)
The next step is to build the AdaBoost classifier. We can do this using ...
Read now
Unlock full access