Ankita
Ankita

Reputation: 485

Getting False positives and False negatives relevant datasets of confusion matrix?

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

Upvotes: 1

Views: 468

Answers (1)

Arturo Sbr
Arturo Sbr

Reputation: 6333

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]

Upvotes: 2

Related Questions