Confusion Matrix for Undersupervised Classification in Google Earth Engine

by Vince Alonte   Last Updated April 16, 2019 07:22 AM

I am having trouble in creating a confusion matrix for the k means unsupervised classification since the confusion matrix in Google Earth engine are for classifiers only and not clusterers. Can anyone instruct or show me how this is done? My code is done below. Thank you so much!

var region = /* color: #d63000 */ee.Geometry.Polygon(
        [[[119.68178880811138, 15.887943792271113],
          [119.68727478669007, 15.466414056463597],
          [120.2307776726143, 15.443926441847232],
          [120.1454064641074, 15.944688246152472],
          [120.08364465416514, 16.1425369132892],
          [119.66642075655432, 16.055508335477374]]]);

//Archive Image Sentinel 1
var archive = ee.Image("COPERNICUS/S1_GRD/S1A_IW_GRDH_1SSV_20150928T100640_20150928T100705_007914_00B0C9_029A").select('VV');
print (archive);
Map.addLayer(archive,{min:-25.0, max:0.0},'Archive',0);
Map.centerObject(archive)

// Make the training dataset.
var atraining = archive.sample({
  region: region,
  scale: 30,
  numPixels: 5000
});

// Instantiate the clusterer and train it.
var aclusterer = ee.Clusterer.wekaKMeans(2).train(atraining);

// Cluster the input using the trained clusterer.
var aresult = archive.cluster(aclusterer);

// Display the clusters with random colors.
Map.addLayer(aresult, {min: 0, max: 1, palette: [
 '0b4a8b',// water blue
  'ffc82d', // nonwater yellow
  ]}, 'K Means Archive',1);


Related Questions


Updated February 12, 2017 14:09 PM

Updated December 16, 2017 04:22 AM

Updated July 23, 2018 12:22 PM

Updated June 20, 2017 16:22 PM

Updated May 29, 2015 00:09 AM