ee.ConfusionMatrix

สร้างเมตริกซ์ความสับสน แกน 0 (แถว) ของเมทริกซ์สอดคล้องกับค่าจริง และแกน 1 (คอลัมน์) สอดคล้องกับค่าที่คาดการณ์

การใช้งานการคืนสินค้า
ee.ConfusionMatrix(array, order)ConfusionMatrix
อาร์กิวเมนต์ประเภทรายละเอียด
arrayวัตถุอาร์เรย์ 2 มิติของจำนวนเต็มที่เป็นสี่เหลี่ยมจัตุรัสซึ่งแสดงเมทริกซ์ความสับสน โปรดทราบว่าอาร์กิวเมนต์นี้ใช้รายการไม่ได้ ซึ่งต่างจากตัวสร้าง ee.Array
orderรายการ (ค่าเริ่มต้น: null)ขนาดและลำดับของแถวและคอลัมน์สำหรับเมตริกซ์ที่ไม่ต่อเนื่องหรือเมตริกซ์ที่ไม่ได้อิงตามศูนย์

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (JavaScript)

// A confusion matrix. Rows correspond to actual values, columns to
// predicted values.
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]]);
print('Constructed confusion matrix',
      ee.ConfusionMatrix(array));

// The "order" parameter refers to row and column class labels. When
// unspecified, the class labels are assumed to be a 0-based sequence
// incrementing by 1 with a length equal to row/column size.
print('Default row/column labels (unspecified "order" parameter)',
      ee.ConfusionMatrix({array: array, order: null}).order());

// Set the "order" parameter when custom class label integers are required. The
// list of integer value labels should correspond to the matrix axes left to
// right / top to bottom.
var order = [11, 22, 42, 52, 71, 81];
print('Specified row/column labels (specified "order" parameter)',
      ee.ConfusionMatrix({array: array, order: order}).order());

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า สภาพแวดล้อม Python

import ee
import geemap.core as geemap

Colab (Python)

from pprint import pprint

# A confusion matrix. Rows correspond to actual values, columns to
# predicted values.
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]])
print('Constructed confusion matrix:')
pprint(ee.ConfusionMatrix(array).getInfo())

# The "order" parameter refers to row and column class labels. When
# unspecified, the class labels are assumed to be a 0-based sequence
# incrementing by 1 with a length equal to row/column size.
print('Default row/column labels (unspecified "order" parameter):',
      ee.ConfusionMatrix(array, None).order().getInfo())

# Set the "order" parameter when custom class label integers are required. The
# list of integer value labels should correspond to the matrix axes left to
# right / top to bottom.
order = [11, 22, 42, 52, 71, 81]
print('Specified row/column labels (specified "order" parameter):',
      ee.ConfusionMatrix(array, order).order().getInfo())