Confusion matrix issue

400
1
08-15-2022 02:01 AM
Labels (3)
JohnCregan
New Contributor

So I am trying to create an accuracy assessment for some sites in an image that I have been working on. My work so far has been drawing polygons around areas of wetland in an image from 1995, and doing the same for the same area in 2014, and computing the difference in polygon size in m^2 in order to detect erosion of the sites.

I went to the sites and collected ground truth data within the study areas (GPS points). I classified in the field wether or not the points were (1) wetland, (2) eroded or (3) grass/shrub Now I am trying to create a confusion matrix for these points by classifying the same points I collected in the field (the ground truth data) within arcGIS by eye (in order to mimic how arcGIS would classify the images based off of pixel values).

Where I am struggling is in actually creating a feature layer with an attribute table that contains both my GPS points and their groundtruth classification as well as the classification I gave to them manually, and then feeding this layer into the compute confusion matrix tool. If you can provide any help at all I would really appreciate it. Thank you

0 Kudos
1 Reply
WadeWall
Occasional Contributor

Hi John,

Where are you in the process? Do you have a shapefile with the values? If so, you can import the shapefile attribute table as a numpy array and then use do it within python.

Something kind of like this.

from sklearn.metrics import confusion_matrix

shp = 'path\\to\\shapefile.shp'
truth = arcpy.da.TableToNumPyArray(shp,'truth')
model = arcpy.da.TableToNumPyArray(shp,'model')
cm =confusion_matrix(model, truth)
0 Kudos