ee.ConfusionMatrix.order
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
// 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
# 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."],[[["`ConfusionMatrix.order()` returns a list containing the names and order of rows and columns within the confusion matrix."],["By default, `ConfusionMatrix` automatically assigns an order to rows and columns if not explicitly specified."],["Users can define a custom order for rows and columns when creating a `ConfusionMatrix` using the `order` parameter."],["This function is crucial for understanding the structure and organization of a confusion matrix, especially when interpreting its values."]]],["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"]]