welcome smileGradientTreeBoost

A very nice addition to the classifiers

Use the code below or see the example here

var cambodia = ee.FeatureCollection("users/servirmekong/countries/KHM_adm1");
var KampongThum = cambodia.filter(ee.Filter.eq("NAME_1","Kâmpóng Thum")).geometry();


Map.addLayer(image,{min:0,max:0.6,bands:"swir1,nir,red"},"composite");

var TrainingData = water.merge(forest).merge(rubber).merge(urban).merge(wetlands).merge(agriculture);

var covariates = require("users/servirmekong/mrc:covariate_module");

image = covariates.addJRCAndTopo(image);
image = covariates.addCovariates(image);


var trainingSample = image.sampleRegions(TrainingData,["land_class"],10)

var bandNames = image.bandNames();

/* random forest */
var classifier = ee.Classifier.smileRandomForest(10).train(trainingSample,"land_class",bandNames);

var classification = image.classify(classifier,'Mode');

Map.addLayer(classification.clip(KampongThum),{min:0,max:5,palette:"aec3d4,152106,387242,cc0013,3bc3b2,8dc33b"},"landcover")

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


/* boosted trees */
var classifier = ee.Classifier.smileGradientTreeBoost(10).train(trainingSample,"land_class",bandNames);

var classification = image.classify(classifier,'Mode');

Map.addLayer(classification.clip(KampongThum),{min:0,max:5,palette:"aec3d4,152106,387242,cc0013,3bc3b2,8dc33b"},"landcover boosted trees")


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

Leave a Reply