Can Matlab display all the false positive/negative images from a confusion matrix automatically?

4 views (last 30 days)
Hi! I am training a multiclass image recognition algorithm and some classes are producing large numbers of false positives. I'd like to study the images of the false positives to see if I can determine what is causing the problem. I know I can go into the array for my confusion matrix and locate the FPs by hand, but I'm dealing with a very large imageset. If there's a way I can have all the false positive/negative images presented to me automatically with some code, that would be a major help! Thank you in advance!

Answers (1)

Aravind
Aravind on 17 Oct 2024
It sounds like you're looking to pinpoint which images in your dataset are leading to false positives. To achieve this, you will need two lists: one with the actual class labels and another with the predicted class labels. You can use these two lists to identify cases where the model incorrectly predicts a specific class, even though the actual class is different.
A straightforward approach to accomplish this is given below:
Prepare Your Inputs:
  1. Create a list or array containing the true class labels.
  2. Create a corresponding list or array with the predicted class labels.
  3. Get the specific class for which you want to find false positives.
Implement a Function:
  1. Iterate over each element in the predicted labels.
  2. For each element, check:
- If the predicted label matches the specified target class.
- If the true label for that element is different from the target class.
Identify False Positives:
  1. If both of the above conditions are true, it means the model predicted the target class incorrectly, marking it as a false positive.
  2. Gather all indices where false positives occur. This will help you locate the images in your dataset responsible for these false positives.
By following this method, you can efficiently identify and examine the images that are causing false positives.
I hope this answers your question.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!