I am trying to do a Random Forest in Google Earth Engine. My data is unbalanced (more or less I have 3 times more points of one class) so I want to balance them. I tried to give different weights to my classes but it doesn't work.
Any suggestions?
Here is the code I am using:
var polygons = table4; var sample = polygons.randomColumn(); var trainingsample = sample.filter('random <= 0.8'); var validationsample = sample.filter('random > 0.8'); var NoNull = trainingsample.filter(ee.Filter.notNull(trainingsample.first().propertyNames())); print('Training sample', trainingsample); print('Validation sample', validationsample); var bands =['b1', 'b3', 'b4', 'b6', 'b7', 'b8', 'b9', 'b10', 'b11'];//Recordar canviar les bandes que es van a utilitzar segons el tipus de RF que anem a fer. Map.addLayer (trainingsample,{color:'black'}); Map.addLayer (validationsample,{color:'white'}); //Definr pesos para equilibrar las clases var weights = ee.Dictionary({ clase1: 1, clase2: 2 }); //var RFclassifier = ee.Classifier.smileRandomForest(500).train(training, 'Class'); var RFclassifier = ee.Classifier.randomForest({ numberOfTrees: 1000, variablesPerSplit: 3, minLeafPopulation: 1, bagFraction: 0.5 }).train({ features:trainingsample, classProperty: 'arboles', inputProperties: ['bands'], weights: 'weights' }); print('Results of trained classifier', RFclassifier.explain()); I am new in using Google Earth Engine.