Announcement: All noncommercial projects registered to use Earth Engine before
April 15, 2025 must
verify noncommercial eligibility to maintain Earth Engine access.
ee.ConfusionMatrix.array
Stay organized with collections
Save and categorize content based on your preferences.
Returns a confusion matrix as an Array.
Usage | Returns | ConfusionMatrix.array() | Array |
Argument | Type | Details | this: confusionMatrix | ConfusionMatrix | |
Examples
Code Editor (JavaScript)
// Construct a confusion matrix from an array (rows are actual values,
// columns are predicted values). We construct a confusion matrix here for
// brevity and clear 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 confusionMatrix = ee.ConfusionMatrix(array);
print("ee.ConfusionMatrix", confusionMatrix);
print("ee.ConfusionMatrix as ee.Array", confusionMatrix.array());
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)
from pprint import pprint
# Construct a confusion matrix from an array (rows are actual values,
# columns are predicted values). We construct a confusion matrix here for
# brevity and clear 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]])
confusion_matrix = ee.ConfusionMatrix(array)
print("ee.ConfusionMatrix:")
pprint(confusion_matrix.getInfo())
print("ee.ConfusionMatrix as ee.Array:")
pprint(confusion_matrix.array().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\u003eThe \u003ccode\u003eConfusionMatrix.array()\u003c/code\u003e function returns the confusion matrix as an \u003ccode\u003eee.Array\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eThis function is used to access the underlying data of an \u003ccode\u003eee.ConfusionMatrix\u003c/code\u003e object for further analysis or visualization.\u003c/p\u003e\n"],["\u003cp\u003eThe confusion matrix represents the performance of a classifier, with rows indicating actual values and columns indicating predicted values.\u003c/p\u003e\n"],["\u003cp\u003eYou can create an \u003ccode\u003eee.ConfusionMatrix\u003c/code\u003e from an existing \u003ccode\u003eee.Array\u003c/code\u003e or by using the \u003ccode\u003eee.Classifier.confusionMatrix()\u003c/code\u003e function.\u003c/p\u003e\n"]]],[],null,["# ee.ConfusionMatrix.array\n\nReturns a confusion matrix as an Array.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------------|---------|\n| ConfusionMatrix.array`()` | Array |\n\n| Argument | Type | Details |\n|-------------------------|-----------------|---------|\n| this: `confusionMatrix` | ConfusionMatrix | |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Construct a confusion matrix from an array (rows are actual values,\n// columns are predicted values). We construct a confusion matrix here for\n// brevity and clear visualization, in most applications the confusion matrix\n// will be 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]]);\nvar confusionMatrix = ee.ConfusionMatrix(array);\nprint(\"ee.ConfusionMatrix\", confusionMatrix);\n\nprint(\"ee.ConfusionMatrix as ee.Array\", confusionMatrix.array());\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\nfrom pprint import pprint\n\n# Construct a confusion matrix from an array (rows are actual values,\n# columns are predicted values). We construct a confusion matrix here for\n# brevity and clear visualization, in most applications the confusion matrix\n# will be 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]])\nconfusion_matrix = ee.ConfusionMatrix(array)\nprint(\"ee.ConfusionMatrix:\")\npprint(confusion_matrix.getInfo())\n\nprint(\"ee.ConfusionMatrix as ee.Array:\")\npprint(confusion_matrix.array().getInfo())\n```"]]