Home > Back-end >  Getting False positives and False negatives relevant datasets of confusion matrix?
Getting False positives and False negatives relevant datasets of confusion matrix?

Time:10-27

I ran a random classifier on my text data and calculated a confusion matrix using the following code

#Plot the confusion matrix
plot_confusion_matrix(y_test, y_pred, normalize=False,figsize=(15,8))

See

The above fig is what my confusion matrix looks like. Now, I want to see some datasets that belong to False positives and False negatives? In short, I want to see data which the classifier incorrectly labelled. How can I do this? Thanks in advance

CodePudding user response:

Assuming that you have some object x_test, you could filter the rows where the prediction and the true label are different from one another.

# Visualize observations that were incorrectly labeled
x_test[y_test != y_pred]
  • Related