Skip To Content

Compute Confusion Matrix

Available with Spatial Analyst license.

Available with Image Analyst license.

Summary

Computes a confusion matrix with errors of omission and commission, then derives a kappa index of agreement and an overall accuracy between the classified map and the reference data.

This tool uses the outputs from the Create Accuracy Assessment Points tool or the Update Accuracy Assessment Points tool.

Usage

  • This tool computes a confusion matrix using the random accuracy assessment points. The accuracy assessment points are generated by the Create Accuracy Assessment Points tool and updated by the Update Accuracy Assessment Points tool. Those two tools ensure that each point with have valid class values for the CLASSIFIED and GROUND_TRUTH fields. The tool calculates the user's accuracy and producer's accuracy for each class as well as an overall kappa index of agreement. These accuracy rates range from 0 to 1, where 1 represents 100 percent accuracy. Below is an example of a confusion matrix.

    c_1

    c_2

    c_3

    Total

    U_Accuracy

    Kappa

    c_1

    49

    4

    4

    57

    0.8594

    0

    c_2

    2

    40

    2

    44

    0.9091

    0

    c_3

    3

    3

    59

    65

    0.9077

    0

    Total

    54

    47

    65

    166

    0

    0

    P_Accuracy

    0.9074

    0.8511

    0.9077

    0

    0.8916

    0

    Kappa

    0

    0

    0

    0

    0

    0.8357

    Confusion matrix example

  • User's accuracy shows false positives, where pixels are incorrectly classified as a known class when they should have been classified as something else. An example would be where the classified image identifies a pixel as impervious, but the reference identifies it as forest. The impervious class has extra pixels that it should not have according to the reference data.

    User's accuracy is also referred to as errors of commission, or type 1 error. The data to compute this error rate is read from the rows of the table.

    The Total row shows the number of points that should have been identified as a given class, according to the reference data.

  • Producer's accuracy is a false negative, where pixels of a known class are classified as something other than that class. An example would be where the classified image identifies a pixel as forest, but it should be actually be impervious. In this case, the impervious class is missing pixels according to the reference data.

    Producer's accuracy is also referred to as errors of omission, or type 2 error. The data to compute this error rate is read in the columns of the table.

    The Total column shows the number of points that were identified as a given class, according to the classified map.

  • Kappa index of agreement gives an overall assessment of the accuracy of the classification.

Syntax

ComputeConfusionMatrix (in_accuracy_assessment_points, out_confusion_matrix)
ParameterExplanationData Type
in_accuracy_assessment_points

The accuracy assessment point feature class, created from the Create Accuracy Assessment Points tool, containing the CLASSIFIED and GROUND_TRUTH fields.

Feature Layer
out_confusion_matrix

The output file name of the confusion matrix in table format.

The format of the table is determined by the output location and path. By default, the output will be a geodatabase table. If the path is not in a geodatabase, specify a .dbf extension to save it in dBASE format.

Table

Code sample

ComputeConfusionMatrix example 1 (stand-alone script)

This example computes the confusion matrix based on accuracy assessment points.

import arcpy
from arcpy.sa import *

arcpy.gp.ComputeConfusionMatrix("aapnt2.shp", "confm.dbf")

Licensing information

  • ArcGIS Desktop Basic: Requires Spatial Analyst or Image Analyst
  • ArcGIS Desktop Standard: Requires Spatial Analyst or Image Analyst
  • ArcGIS Desktop Advanced: Requires Spatial Analyst or Image Analyst

Related topics