I have been working with the tutorials in GEE on supervised and unsupervised classification, but I haven't come across any examples on the use of separability measures such as Jeffreys-Matusita, transformed divergence or B-distance for instance.

Here's my code to run a classification using CART()

// Add a clipping function to clip the image collection

var clipper = function(image){
  return image.clip(WG);

// Import raw Landsat 5 scenes and clip them over your study area
var l5filtered = ee.ImageCollection('LANDSAT/LT05/C01/T1').filterDate('2008-01-01','2012-12-31').map(clipper);

// Obtain a cloud-free composite of the scenes filtered
var cloudfree = ee.Algorithms.Landsat.simpleComposite({
  collection: l5filtered,
  asFloat: true
Map.addLayer(cloudfree, {bands: ['B4','B3','B2'], max: 0.3}, 'composite');

// Specify the bands of the Landsat composite to be used as predictors (p)
var predictionBands = ['B1','B2','B3','B4','B5','B6','B7'];

// Step 2: Creating training data manually
// Draw a polygon around a bare ground area and import it as a featureCollection
// Click New property and import the new 'class' and give it a value of 0
// Similarly vegetation and water features were created

// Merging the three featureCollections to obtain a single featureCollection
var trainingFeatures = bare.merge(vegetation).merge(water);

// Note - we use .sampleRegions, if we have a featureCollection and we want to sample an image
// given a featureCollection

var classifierTraining = cloudfree.select(predictionBands)
                                    collection: trainingFeatures,
                                    properties : ['class'],
                                    scale: 30

// Let's instantiate a CART and train it
var classifier = ee.Classifier.cart().train({
                   features: classifierTraining,
                   classProperty: 'class',
                   inputProperties: predictionBands

// Classify the image
var classified = cloudfree.select(predictionBands).classify(classifier);
Map.addLayer(classified, {min:0, max:2, palette: ['red','green','blue']}, 'classified');

// Step 1: Partition the set of known values into training and testing sets

// Adding a randomColumn of values ranging from 0 to 1
var trainingTesting = classifierTraining.randomColumn();

var trainingSet = trainingTesting.filter(ee.Filter.lt('random',0.6));
var testingSet = trainingTesting.filter(ee.Filter.gte('random',0.6));

// Now run the classifier only with the trainingSet
var trained = ee.Classifier.cart().train({
  features: trainingSet,
  classProperty: 'class',
  inputProperties: predictionBands

// Now classify the testData and obtain a Confusion matrix
var confusionMatrix = ee.ConfusionMatrix(testingSet.classify(trained)
                                                     actual: 'class',
                                                     predicted: 'classification'

// Now print the ConfusionMatrix and expand the object to inspect the matrix()
// One can also obtain basic descriptive statistics from the confusionMatrix
print('Confusion matrix:', confusionMatrix);
print('Overall Accuracy:', confusionMatrix.accuracy());
print('Producers Accuracy:', confusionMatrix.producersAccuracy());
print('Consumers Accuracy:', confusionMatrix.consumersAccuracy());

Unsure of how to calculate separability measures. I have shared the assets necessary. Here's the code link as well - https://code.earthengine.google.com/cb156ba6f71b6448f08bf106162c6373

Your Answer

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

Browse other questions tagged or ask your own question.