confusion matrix of the final result
step 1: add the resulting land cover map and reference data
var image = ee.Image("users/servirmekong/Vietnam/landCoverMap"); var referenceData = ee.FeatureCollection("users/servirmekong/Vietnam/ReferenceDataForestTraining");
step 2: Take the 20% of data you didnt use for training the model
var referenceData = referenceData.randomColumn("random"); var sample = referenceData.filter(ee.Filter.gt("random",0.8)); Map.addLayer(sample)
step 3: Sample the land cover map
var validation = image.sampleRegions(sample,["land_class"],10);
step 4: calculate the error matrix
var confMatrix = validation.errorMatrix("land_class","Mode"); var OA = confMatrix.accuracy(); var CA = confMatrix.consumersAccuracy(); var Kappa = confMatrix.kappa(); var Order = confMatrix.order(); var PA = confMatrix.producersAccuracy(); print(confMatrix,'Confusion Matrix'); print(OA,'Overall Accuracy'); print(CA,'Consumers Accuracy'); print(Kappa,'Kappa'); print(Order,'Order'); print(PA,'Producers Accuracy');
step 5: Add the image to the map (optional)
Map.addLayer(image,{min:0,max:4,palette:"blue,purple,darkred,yellow,darkgreen"},"land cover map");<span id="mce_SELREST_start" style="overflow:hidden;line-height:0"></span>