After classification of an image in GEE, I got 2 lists of user's and producer's accuracies (1*7 and 7*1 dimensions). How can I calculate an average value for each of them now?

print('Validation consumersAccuracy: ', testAccuracy.consumersAccuracy());
print('Validation producersAccuracy: ', testAccuracy.producersAccuracy());

Applying the list reducer does not work.

var meanConsumer=ee.List(testAccuracy.consumersAccuracy()).reduce(ee.Reducer.mean())

Here is the whole code (it's not actually mine, I am new at GEE) https://code.earthengine.google.com/b9ebf87363121a6e51a980dfea187166

1 Answer 1


This one is a bit tricky, since GEE prints the result of .consumersAccuracy as the type List but the function actually returns an Array (see the documentation).

The array is 1-dimensional and as such the console interprets/displays it as a list. To get the mean you have to use an array instead of a list reducer. Note that the array reducers requires the axis to reduce over - in the case of a 1D array that would be [0,1].

print('Mean consumersAccuracy:', testAccuracy.consumersAccuracy().reduce(ee.Reducer.mean(), [0,1]))
  • It works now! Thanks a lot, Kersten, for your help!
    – Lena Ok
    May 27, 2018 at 13:31

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.