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())
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eCreates a confusion matrix from a 2D array of integers, where rows represent actual values and columns represent predicted values.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eorder\u003c/code\u003e parameter can be used to specify custom class labels for the rows and columns of the matrix.\u003c/p\u003e\n"],["\u003cp\u003eIf \u003ccode\u003eorder\u003c/code\u003e is not specified, it defaults to a 0-based sequence incrementing by 1.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eee.ConfusionMatrix\u003c/code\u003e object provides methods for analyzing the confusion matrix.\u003c/p\u003e\n"]]],[],null,["# ee.ConfusionMatrix\n\nCreates a confusion matrix. Axis 0 (the rows) of the matrix correspond to the actual values, and Axis 1 (the columns) to the predicted values.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|----------------------------------------|-----------------|\n| `ee.ConfusionMatrix(array, `*order*`)` | ConfusionMatrix |\n\n| Argument | Type | Details |\n|----------|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| `array` | Object | A square, 2D array of integers, representing the confusion matrix. Note that unlike the ee.Array constructor, this argument cannot take a list. |\n| `order` | List, default: null | The row and column size and order, for non-contiguous or non-zero based matrices. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A confusion matrix. Rows correspond to actual values, columns to\n// predicted values.\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]]);\nprint('Constructed confusion matrix',\n ee.ConfusionMatrix(array));\n\n// The \"order\" parameter refers to row and column class labels. When\n// unspecified, the class labels are assumed to be a 0-based sequence\n// incrementing by 1 with a length equal to row/column size.\nprint('Default row/column labels (unspecified \"order\" parameter)',\n ee.ConfusionMatrix({array: array, order: null}).order());\n\n// Set the \"order\" parameter when custom class label integers are required. The\n// list of integer value labels should correspond to the matrix axes left to\n// right / top to bottom.\nvar order = [11, 22, 42, 52, 71, 81];\nprint('Specified row/column labels (specified \"order\" parameter)',\n ee.ConfusionMatrix({array: array, order: order}).order());\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# A confusion matrix. Rows correspond to actual values, columns to\n# predicted values.\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]])\nprint('Constructed confusion matrix:')\npprint(ee.ConfusionMatrix(array).getInfo())\n\n# The \"order\" parameter refers to row and column class labels. When\n# unspecified, the class labels are assumed to be a 0-based sequence\n# incrementing by 1 with a length equal to row/column size.\nprint('Default row/column labels (unspecified \"order\" parameter):',\n ee.ConfusionMatrix(array, None).order().getInfo())\n\n# Set the \"order\" parameter when custom class label integers are required. The\n# list of integer value labels should correspond to the matrix axes left to\n# right / top to bottom.\norder = [11, 22, 42, 52, 71, 81]\nprint('Specified row/column labels (specified \"order\" parameter):',\n ee.ConfusionMatrix(array, order).order().getInfo())\n```"]]