October 2018
Intermediate to advanced
172 pages
4h 6m
English
In order to evaluate the performance of classification, let's consider the two classification algorithms that we have built in this book: k-nearest neighbors and logistic regression.
The first step will be to implement both of these algorithms in the fraud detection dataset. We can do this by using the following code:
import pandas as pdfrom sklearn.model_selection import train_test_splitfrom sklearn.neighbors import KNeighborsClassifierfrom sklearn import linear_model#Reading in the fraud detection dataset df = pd.read_csv('fraud_prediction.csv')#Creating the features features = df.drop('isFraud', axis = 1).valuestarget = df['isFraud'].values#Splitting the data into training and test ...Read now
Unlock full access