ee.ConfusionMatrix.order

Returns the name and order of the rows and columns of the matrix.

UsageReturns
ConfusionMatrix.order()List
ArgumentTypeDetails
this: confusionMatrixConfusionMatrix

Examples

Code Editor (JavaScript)

// Construct an error/confusion matrix from an array (rows are actual values,
// columns are predicted values). We construct an error matrix here for brevity
// and matrix visualization, in most applications the confusion matrix will be
// generated from ee.Classifier.confusionMatrix.
var array = ee.Array([[32, 0, 0,  0,  1, 0],
                      [ 0, 5, 0,  0,  1, 0],
                      [ 0, 0, 1,  3,  0, 0],
                      [ 0, 1, 4, 26,  8, 0],
                      [ 0, 0, 0,  7, 15, 0],
                      [ 0, 0, 0,  1,  0, 5]]);

var cmDefaultOrder = ee.ConfusionMatrix(array);
print('Default name and order of the rows and columns',
      cmDefaultOrder.order());

var order = [11, 22, 42, 52, 71, 81];
var cmSpecifiedOrder = ee.ConfusionMatrix({array: array, order: order});
print('Specified name and order of the rows and columns',
      cmSpecifiedOrder.order());

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

import ee
import geemap.core as geemap

Colab (Python)

# Construct an error/confusion matrix from an array (rows are actual values,
# columns are predicted values). We construct an error matrix here for brevity
# and matrix visualization, in most applications the confusion matrix will be
# generated from ee.Classifier.confusionMatrix.
array = ee.Array([[32, 0, 0,  0,  1, 0],
                  [ 0, 5, 0,  0,  1, 0],
                  [ 0, 0, 1,  3,  0, 0],
                  [ 0, 1, 4, 26,  8, 0],
                  [ 0, 0, 0,  7, 15, 0],
                  [ 0, 0, 0,  1,  0, 5]])

cm_default_order = ee.ConfusionMatrix(array)
print('Default name and order of the rows and columns:',
      cm_default_order.order().getInfo())

order = [11, 22, 42, 52, 71, 81]
cm_specified_order = ee.ConfusionMatrix(array, order)
print('Specified name and order of the rows and columns:',
      cm_specified_order.order().getInfo())