Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.ConfusionMatrix.array

  • Thearray() method returns a confusion matrix as anArray.

  • Thearray() method is called on aConfusionMatrix object.

  • The examples demonstrate how to create aConfusionMatrix and then retrieve its array representation in both JavaScript and Python.

Returns a confusion matrix as an Array.

UsageReturns
ConfusionMatrix.array()Array
ArgumentTypeDetails
this:confusionMatrixConfusionMatrix

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.vararray=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]]);varconfusionMatrix=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 usinggeemap for interactive development.

importeeimportgeemap.coreasgeemap

Colab (Python)

# 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)display("ee.ConfusionMatrix:",confusion_matrix)display("ee.ConfusionMatrix as ee.Array:",confusion_matrix.array())

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023-10-06 UTC.