# Confusion Matrix for Red Analyze

The Confusion Matrix is a visual representation of the ground truth versus the tool's predictions. The confusion matrix in Red Analyze Tool is a comparison table of the tool processing results showing the relationships between the Actual values and the Predicted values. The confusion matrix and its performance metrics (the precision, recall, and F1 score of confusion matrix), which will be explained more below, are offered both in Red Analyze Supervised (Red Analyze Focused Supervised, Red Analyze High Detail) and Red Analyze Focused Unsupervised.

## Counting Confusion Matrix

There are 4 ways to populate this table by Count dropdown option: Views, Untrained Views, Regions, and Untrained region. These are also used to draw "Score" graph (Score Distribution Graph).

- Views: A label and a marking are imprinted on each view

- Untrained Views: A label and a marking are imprinted on each view that does not belong to the training set.

- Regions: A label and a marking are imprinted on each region in a view. Regions are split into the defect regions (bad) and the backgrounds (good), labeled and marked as per them.

- Untrained Regions: A label and a marking are imprinted on each pixel in a view that does not belong to the training set. Regions are split into the defects (bad pixels) and the background (good pixels), labeled and marked as per them.

Note:
There are two types of labeling for Red Analyze: Pixel-wise labeling and view-wise labeling.

- Pixel-wise labeling: right-click on Image Display Area → click "Edit Regions" → draw a defect region and click "Apply"

- View-wise labeling: right-click on a view in View Browser→ click "Label Views" → select "Bad"

When you label an entire view itself as "Bad"(view-wise), and that is view-wise labeling used in Views/Untrained Views. But when you label one or more pixels as "Bad" (pixel-wise), and that is pixel-wise labeling used in Regions/Untrained Regions.
For Regions/Untrained Regions, a pixel that is not labeled at all is considered to be labeled as "Good" (The backgrounds). The marking is the prediction of whether a pixel is a defect pixel or not by checking the defect probability of this pixel goes over T1. Note that a view that has pixel-wise defect label(s) is automatically also labeled as "Bad" in view level.