Project - Credit Card Fraud Detection using Machine Learning

23 / 25

Visualize the Confusion Matrix

Let us visualize the confusion matrices for the predictions made on the test set and over-sampled train set.

Note:

plot_confusion_matrix(estimator, X, y) plots Confusion Matrix. Here estimator is the fitted classifier, X is the input values and y is the target values.

INSTRUCTIONS
  • Import plot_confusion_matrix from sklearn.metrics

    from << your code comes here >> import << your code comes here >>
    
  • Write the class names.

    class_names = ['Not Fraud', 'Fraud']
    
  • Call the plot_confusion_matrix function and pass k, X_test, y_test as arguments.

    << your code comes here >>(k, X_test, y_test,  values_format = '.5g', display_labels=class_names)
    plt.title("Test data Confusion Matrix")
    plt.show()
    
  • Call the plot_confusion_matrix function and pass k, X_train_res, y_train_res as arguments.

    << your code comes here >>(k, X_train_res, y_train_res,  values_format = '.5g', display_labels=class_names) 
    plt.title("Oversampled Train data Confusion Matrix")
    plt.show()
    
Get Hint See Answer


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

Loading comments...