October 2018
Intermediate to advanced
172 pages
4h 6m
English
Now that you have learned how the Naive Bayes algorithm generates predictions, we will implement the same classifier using scikit-learn, in order to predict whether a particular transaction is fraudulent.
The first step is to import the data, create the feature and target arrays, and split the data into training and test sets.
We can do this by using the following code:
import pandas as pdfrom sklearn.model_selection import train_test_splitdf = pd.read_csv('fraud_prediction.csv')df = 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 ...Read now
Unlock full access