公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ee.ConfusionMatrix.array
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
以陣列形式傳回混淆矩陣。
用量 | 傳回 |
---|
ConfusionMatrix.array() | 陣列 |
引數 | 類型 | 詳細資料 |
---|
這個:confusionMatrix | ConfusionMatrix | |
範例
程式碼編輯器 (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 設定
請參閱
Python 環境頁面,瞭解 Python API 和如何使用 geemap
進行互動式開發。
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())
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\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```"]]