Available with Spatial Analyst license.
Summary
Estimates the accuracy of individual training samples. The cross validation accuracy is computed using the previously generated classification training result in an .ecd file and the training samples. Outputs include a raster dataset containing the misclassified class values and a training sample dataset with the accuracy score for each training sample.
Usage
The tool uses the input raster, an additional input raster, and the .ecd classifier definition file to produce an on-the-fly classification layer. This classification layer is then used as reference and compared to all training sample polygons or points. Since an ideal training sample should contain only pixels of the class it represents, the accuracy is computed by comparing all the correctly classified pixels with all the incorrectly classified pixels for each training sample. The accuracy score (per polygon/point) is computed as number of correctly classified pixels / number of total pixels contained in each training sample.
The score can range as a decimal value from 0 to 1 for polygon training samples. The score is either 0 or 1 for point training samples.
The results can be used in the following ways to improve training samples defining classes:
- Use the attribute table of the output training sample to sort the training features by accuracy and zoom to each feature.
- Use the misclassified raster class map to view where classification confusion exists and what is causing it.
- Using this information, you can make a decision to keep, remove, or edit the training features.
Syntax
InspectTrainingSamples (in_raster, in_training_features, in_classifier_definition, out_training_feature_class, out_misclassified_raster, {in_additional_raster})
Parameter | Explanation | Data Type |
in_raster | The input raster to be classified. | Mosaic Layer; Raster Layer; Image Service; String |
in_training_features | A training sample feature class created in the Training Samples Manager pane. | Feature Layer; Feature Class; Raster Catalog Layer |
in_classifier_definition | The .ecd output classifier file from any of the train classifier tools. The .ecd file is a JSON file that contains attribute information, statistics, or other information needed for the classifier. | File |
out_training_feature_class | Output individual training samples saved as a feature class. The associated attribute table contains an addition field listing the accuracy score. | Feature Class |
out_misclassified_raster | Output misclassified raster having NoData outside training samples. In training samples, correctly classified pixels are represented as NoData, and misclassified pixels are represented by their class value. The results is an index map of misclassified class values. | Raster Dataset |
in_additional_raster (Optional) | Optionally incorporate ancillary raster datasets, such as a multispectral image or a DEM, to generate attributes and other required information for the classifier. This raster will be needed when calculating attributes such as mean or standard deviation. | Mosaic Layer; Raster Layer; Image Service; String |
Code sample
InspectTrainingSamples example 1 (Python window)
This example inspects the suitability of training samples for classification.
### InspectTrainingSamples example 1 (Python window)
import arcpy
from arcpy.sa import *
in_img = "C:/Data/wv2.tif"
trn_samples1 = "C:/out/ts.shp"
ecd = "C:/Data/svm.ecd"
seg_in_img = "C:/Data/seg.tif"
trn_samples2 = "C:/out/ts2.shp"
out_misclassified_raster = InspectTrainingSamples(in_img, trn_samples, ecd,
trn_samples2, seg_in_img);
out_misclassified_raster.save("C:/temp/misclassified.tif")
InspectTrainingSamples example 2 (stand-alone script)
This example inspects the suitability of training samples for classification.
### InspectTrainingSamples example 2 (stand-alone script)
import arcpy
from arcpy.sa import *
out_misclassified_raster = InspectTrainingSamples("C:/Data/wv2.tif",
"C:/out/ts.shp",
"C:/Data/svm.ecd",
"C:/out/ts2.shp",
"C:/Data/seg.tif");
out_misclassified_raster.save("C:/temp/misclassified.tif")
Environments
Licensing information
- ArcGIS Desktop Basic: Requires Spatial Analyst
- ArcGIS Desktop Standard: Requires Spatial Analyst
- ArcGIS Desktop Advanced: Requires Spatial Analyst