ee.ConfusionMatrix.array

  • The array() method returns a confusion matrix as an Array .

  • The array() method is called on a ConfusionMatrix object.

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

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)

 # 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 
 ()) 
Create a Mobile Website
View Site in Mobile | Classic
Share by: