confusionMatrix
Syntax
Description
[
computes the confusion matrix for all overlap thresholds in the confMat
,confusionClassNames
] = confusionMatrix(metrics
)OverlapThreshold
property of
metrics
, and returns the confusion matrix and the class
names. The function considers all segmentations to compute the confusion
matrix.
[
specifies one or more name-value arguments. For example,
confMat
,confusionClassNames
] = confusionMatrix(metrics
,Name=Value
)ScoreThreshold=0.3
specifies to disregard segmentations with
a confidence score value below 0.3
when computing the confusion
matrix.
Input Arguments
metrics
— Instance segmentation metrics
instanceSegmentationMetrics
object
Instance segmentation performance metrics, specified as an instanceSegmentationMetrics
object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: confusionMatrix(metrics,ScoreThreshold=0.3)
specifies
segmentations with a confidence score value below 0.3
to be
disregarded when computing the confusion matrix.
ScoreThreshold
— Confidence score threshold values
0
(default) | numeric scalar in range [0, 1]
| numeric vector
Confidence score threshold values to use for computing the confusion
matrix, specified as a numeric scalar in the range [0,
1]
or a numeric vector of values in the range [0,
1]
. The function filters out predictions with confidence
scores less than the threshold value when evaluating the confusion
matrix.
Increase this value to reduce the number of false positives, at the possible expense of missing some true positives.
OverlapThreshold
— Overlap threshold values
numeric scalar | numeric vector
Overlap threshold values to use for computing the confusion matrix,
specified as a numeric scalar or numeric vector. Each overlap threshold
value must be an element of the OverlapThreshold
property of the instanceSegmentationMetrics
object. By default, the
function returns the confusion matrix computed at all the overlap
thresholds specified by the OverlapThreshold
property.
Normalize
— Confusion matrix normalization
false
or
0
(default) | true
or 1
Confusion matrix normalization option, specified as a numeric or
logical 0
(or false
) or
1
(or true
). If you specify
Normalize
as true
, the
function normalizes the elements of the confusion matrix in the
confMat
argument by the number of objects known
to belong to each class. For each overlap threshold, each element
(i, j) in the normalized
confusion matrix is the count of objects known to belong to class
i, but predicted to belong to class
j, divided by the total number of objects
predicted in class j.
Output Arguments
confMat
— Confusion matrix
M-by-N cell array
Confusion matrix, returned as an
M-by-N cell array.
M is the number of confidence score thresholds
specified by the ScoreThreshold
argument, and
N is the number of overlap thresholds specified by
the OverlapThreshold
argument.
Each element of the confMat
cell array is a square
numeric matrix of size (C+1)-by-(C+1),
where C is the number of classes. Each element
(i, j) of the matrix is the count
of matched bounding boxes predicted to belong to class
j, but that have a ground truth annotation class of
i.
Row and column C+1 in the confusion matrix correspond to these unmatched conditions:
Column C+1 — Undetected objects, or false negative predictions. Each element in this column is the number of ground truth annotations of the corresponding class unmatched with any predicted bounding box.
Row C+1 — Incorrect predictions, or false positive predictions. Each element in this row is the number of predicted bounding boxes of the corresponding class unmatched with any ground truth annotation.
confusionClassNames
— Class names
string array
Class names corresponding to the returned confusion matrices, returned as
a string array of size (C+1). The elements of the string
array correspond to the classes stored in the
ClassNames
property of the instanceSegmentationMetrics
object
metrics
and an extra background class. The
background class, "background"
, corresponds to the row
and column (C+1) of the confusion matrix, which count the
false positives and false negatives.
Version History
Introduced in R2024b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)