Project - Credit Card Fraud Detection using Machine Learning

13 / 25

Splitting the Data

We have to separate the original data frame into train and test sets.

  • Import the train_test_split from from sklearn.model_selection

    from sklearn.model_selection import << your code comes here >>
  • Split the X, y into train and test sets using train_test_split.

    X_train, X_test, y_train, y_test =  << your code comes here >>(X, y, test_size=0.3, random_state=0)
  • Print the shape of the above split-sets.

    print("Transactions in X_train dataset: ", X_train.shape)
    print("Transaction classes in y_train dataset: ", y_train.shape)
    print("Transactions in X_test dataset: ", X_test.shape)
    print("Transaction classes in y_test dataset: ", y_test.shape)
Get Hint See Answer

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...