AI-generated Key Takeaways
-
The
ConfusionMatrix.order()method returns the name and order of the rows and columns of a confusion matrix as a list. -
This method can be used to retrieve the default order or a specified order assigned during the confusion matrix creation.
-
The examples demonstrate how to use
order()in both JavaScript and Python with confusion matrices constructed from arrays.
| Usage | Returns |
|---|---|
ConfusionMatrix.order() | List |
| Argument | Type | Details |
|---|---|---|
this: confusionMatrix | ConfusionMatrix |
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());
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())