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.