Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-19 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,["Creates 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\nCode 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\nColab (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```"]]