Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
ee.ConfusionMatrix.order
Stay organized with collections
Save and categorize content based on your preferences.
Returns the name and order of the rows and columns of the matrix.
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());
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())
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eConfusionMatrix.order()\u003c/code\u003e returns a list containing the names and order of rows and columns within the confusion matrix.\u003c/p\u003e\n"],["\u003cp\u003eBy default, \u003ccode\u003eConfusionMatrix\u003c/code\u003e automatically assigns an order to rows and columns if not explicitly specified.\u003c/p\u003e\n"],["\u003cp\u003eUsers can define a custom order for rows and columns when creating a \u003ccode\u003eConfusionMatrix\u003c/code\u003e using the \u003ccode\u003eorder\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eThis function is crucial for understanding the structure and organization of a confusion matrix, especially when interpreting its values.\u003c/p\u003e\n"]]],["The `ConfusionMatrix.order()` method returns a list representing the name and order of the rows and columns within a confusion matrix. By default, this order is determined by the matrix's structure. Users can specify a custom order when creating the `ConfusionMatrix`, which will then be reflected in the output of `order()`. The examples illustrate how to retrieve both the default and a user-defined row and column order.\n"],null,["# ee.ConfusionMatrix.order\n\nReturns the name and order of the rows and columns of the matrix.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------|---------|\n| ConfusionMatrix.order`()` | List |\n\n| Argument | Type | Details |\n|-------------------------|-----------------|---------|\n| this: `confusionMatrix` | ConfusionMatrix | |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Construct an error/confusion matrix from an array (rows are actual values,\n// columns are predicted values). We construct an error matrix here for brevity\n// and matrix visualization, in most applications the confusion matrix will be\n// generated from ee.Classifier.confusionMatrix.\nvar array = ee.Array([[32, 0, 0, 0, 1, 0],\n [ 0, 5, 0, 0, 1, 0],\n [ 0, 0, 1, 3, 0, 0],\n [ 0, 1, 4, 26, 8, 0],\n [ 0, 0, 0, 7, 15, 0],\n [ 0, 0, 0, 1, 0, 5]]);\n\nvar cmDefaultOrder = ee.ConfusionMatrix(array);\nprint('Default name and order of the rows and columns',\n cmDefaultOrder.order());\n\nvar order = [11, 22, 42, 52, 71, 81];\nvar cmSpecifiedOrder = ee.ConfusionMatrix({array: array, order: order});\nprint('Specified name and order of the rows and columns',\n cmSpecifiedOrder.order());\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# Construct an error/confusion matrix from an array (rows are actual values,\n# columns are predicted values). We construct an error matrix here for brevity\n# and matrix visualization, in most applications the confusion matrix will be\n# generated from ee.Classifier.confusionMatrix.\narray = ee.Array([[32, 0, 0, 0, 1, 0],\n [ 0, 5, 0, 0, 1, 0],\n [ 0, 0, 1, 3, 0, 0],\n [ 0, 1, 4, 26, 8, 0],\n [ 0, 0, 0, 7, 15, 0],\n [ 0, 0, 0, 1, 0, 5]])\n\ncm_default_order = ee.ConfusionMatrix(array)\nprint('Default name and order of the rows and columns:',\n cm_default_order.order().getInfo())\n\norder = [11, 22, 42, 52, 71, 81]\ncm_specified_order = ee.ConfusionMatrix(array, order)\nprint('Specified name and order of the rows and columns:',\n cm_specified_order.order().getInfo())\n```"]]