Springe direkt zu Inhalt

Code Analysis

Comment every line of the following piece of code! What does it do?

 

This code is used to validate an already processed classification called 'rfclassified' using a validation sample set called 'valMerge'.

Then, an Error Matrix is calculated to evaluate the classifications accuracy.

 

var rfvalidation = rfclassified.sampleRegions({ //Initiates the validation
collection: valMerge, //Choose the merged validation samples
properties: ['landcover'], //Choose geometry field 'landcover' as property
scale: 30, //Set spatial resolution
});
print(rfvalidation, 'Random Forest Validation');//Print the results to the console

var rfTestAccuracy = rfvalidation.errorMatrix('landcover', 'classification'); //Create an Error Matrix for evaluation purposes
print(rfTestAccuracy, 'Validation of the Random Forest Error Matrix'); //Print Error Matrix to the Console
print(rfTestAccuracy.accuracy(), 'Random Forest Overall Accuracy'); //Print Overall Accuracy to the Console