1

I would like to create a classification model through randomForest model. I used Sentinel 2 dataset. Everything is working if I'm using the original bands for the predicted variable. However, if I predict a custom variable (for example NDVI), I get this error:

No valid training data were found.

I'm creating my model this way:

// Model variables
var output = 'B2';              // Working
var output = 'NDVI_GEE';        // Not working -> invalid data
// var output = 'NDVI_custom';     // Not working -> invalid data
var features = ['B4', 'B3'];

// Create random forest model + training
var model = ee.Classifier.randomForest({numberOfTrees:10})
                         .train(train, 
                                output,
                                features);

// Apply classification
var predict = test.limit(50).classify(model)

Maybe is it a question of type ? I tried to cast them with no success.

See the full code on Google Earth Engine.

1

The problem comes from the classifier mode. The default classifier mode is classification mode. Setting it in REGRESSION mode with the setOutputMode solved the issue.

Code:

var model = ee.Classifier.randomForest({numberOfTrees:10})
                         .setOutputMode('REGRESSION')
                         .train(train, 
                                output,
                                features);

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.