0

I performed RF classification in GEE and calculated variable importance with two various scripts successfully. The first script is:

var dict = classifier01.explain();
print('Explain 1:',dict);

var variable_importance = ee.Feature(null, ee.Dictionary(dict).get('importance'));

var chart1 =
ui.Chart.feature.byProperty(variable_importance)
.setChartType('ColumnChart')
.setOptions({ 
title: 'RF Variable Importance - Method 1',
legend: {position: 'none'},
hAxis: {title: 'Bands'},
vAxis: {minValue:0, title: 'Importance'},
});

print(chart1, 'Relative Importance');

The chart obtained from this script is:

enter image description here

The second script and its result are:

print(classifier01.explain(), 'Explain 2:')

var importance = ee.Dictionary(classifier01.explain().get('importance'))

var sum = importance.values().reduce(ee.Reducer.sum())

var relativeImportance = importance.map(function(key, val) {
   return (ee.Number(val).multiply(100)).divide(sum)
  })
print(relativeImportance, 'Relative Importance')

var importanceFc = ee.FeatureCollection([
  ee.Feature(null, relativeImportance)
])

var chart2 = ui.Chart.feature.byProperty({
  features: importanceFc
}).setOptions({
      title: 'RF Variable Importance - Method 2',
      vAxis: {title: 'Importance'},
      hAxis: {title: 'Bands'}
  })
print(chart2, 'Relative Importance')

enter image description here

The OOB error is the same in both methods. Now I am confused about which script and graph is correct or better representative of the variables.

1 Answer 1

0

These are essentially same. Second one is relative values (ie. share in total). What you having is mostly scale effect. Maybe you can try to narrow scale of axis at first chart.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.