2

I'm using Google Earth Engine for Land Cover change detection, I would like to know whether we can generate Error Matrix (Accuracy Assessment) for a classified image in Earth Engine or not?

2

Yes, you can. This page describes how to do it.

// Make a Random Forest classifier and train it.
var classifier = ee.Classifier.randomForest(10)
    .train(training, 'Land_Cover_Type_1');

// Classify the input imagery.
var classified = input.classify(classifier);

// Get a confusion matrix representing resubstitution accuracy.
var trainAccuracy = classifier.confusionMatrix();
print('Resubstitution error matrix: ', trainAccuracy);
print('Training overall accuracy: ', trainAccuracy.accuracy());

// Sample the input with a different random seed to get validation data.
var validation = input.addBands(modis).sample({
  numPixels: 5000,
  seed: 1
  // Filter the result to get rid of any null pixels.
}).filter(ee.Filter.neq('B1', null));

// Classify the validation data.
var validated = validation.classify(classifier);

// Get a confusion matrix representing expected accuracy.
var testAccuracy = validated.errorMatrix('Land_Cover_Type_1', 'classification');
print('Validation error matrix: ', testAccuracy);
print('Validation overall accuracy: ', testAccuracy.accuracy());
  • Accuracy level came almost 90 %, which I think it shouldn't be. Anyway, I appreciate your help, Thank you :) – Tilok Chetri Jul 27 '17 at 16:49
  • 1
    It is important to distinguish between re-substitution accuracy (which should be viewed with extreme caution as a good classifier can reproduce the training set exactly), and test accuracy (the instances of which should be independent of the instances in the training set) which is more likely to reflect the external validity of the classifier. – Nicholas Clinton Jul 27 '17 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.