0

I am Gabriele and I tried to create a scrip for surveying (using Google Earth Engine). Precisely, I am using google earth engine to classify land cover. I found a problem using the ‘Random Forest Classifier’. My purpose is to get a result (see the row ‘gridcoll_classifier’ or the image below) with a value between 0 and 1, but I got binary values only! I attached the whole code right here:

var gridcoll = ee.FeatureCollection('users/gabrielenicolanapoli/gridcoll_merged_modified');

//Classifier
var withRandom = gridcoll.randomColumn('random');

var split = 0.7; //70% training, 30% testing.
var trainingPartition = withRandom.filter(ee.Filter.lt('random', split));
var testingPartition = withRandom.filter(ee.Filter.gte('random', split));

print(trainingPartition)

//Filtering out the null property values and try again.
//var trainingNoNulls = trainingPartition.filter(ee.Filter.notNull(trainingPartition.propertyNames()));

var ClassProperty = 'bool_str';

//Training the classifer and applying it with the filtered training collection.
var gridcoll_classifier = ee.Classifier.smileRandomForest(20).train({
  features: trainingPartition,
  classProperty: ClassProperty,
  inputProperties: ['S_mean', 'S_std']
});
print('Gridcoll Classifier', gridcoll_classifier);

var test = testingPartition.classify(gridcoll_classifier, 'gridcoll_classifier');
print('Gridcoll_test', test);

And the image with the script and the resulting asset…:

1

new name
  • 15,861
  • 19
  • 68
  • 114

1 Answers1

1

You need to set the output mode of the classifier. The default for the smileRandomForest classifier is classification, which is why you get a binary output of 0 or 1.

If you want a probability score for your classification property, try this:

var gridcoll_classifier = ee.Classifier.smileRandomForest(20).train({
  features: trainingPartition,
  classProperty: ClassProperty,
  inputProperties: ['S_mean', 'S_std']
}).setOutputMode('PROBABILITY');

Other options for the output mode are listed in the documentation: https://developers.google.com/earth-engine/apidocs/ee-classifier-setoutputmode

hooge048
  • 224
  • 1
  • 4