Skip to content

Main content

Confusion Label Class Collapse

Explicit nonnegative square confusion table with unique supplied labels, actual rows and predicted columns; collapse both axes through explicit per-label group names, summing every count exactly once; first group appearance defines output order.

Loading tool…

Description

Collapse both axes through explicit per-label group names, summing every count exactly once; first group appearance defines output order.

A confusion table uses actual labels as rows and predicted labels as columns. Cells can contain occurrence counts or supplied nonnegative weights; the axis label order must stay with the matrix. Row, column and joint normalization have different denominators, and a zero denominator needs an explicit undefined result.

Collapse both axes through explicit per-label group names, summing every count exactly once; first group appearance defines output order.

When to use this tool

Use this tool to collapse both axes through explicit per-label group names, summing every count exactly once; first group appearance defines output order.

How to use the tool and how it works

  1. Enter matrix, labels, groups using the input definitions below.
  2. Run the operation. Resolve malformed-input errors before interpreting the result.
  3. Read result.labels, result.matrix. Interpret signs, units, ordering and null values using the rules below.

Require one group name per label. Form output labels in first group-appearance order and sum each original cell exactly once into its actual-group/predicted-group cell.1

Input fieldMeaning and unitsAccepted input
matrixSquare nonnegative finite table: matrix[actualIndex][predictedIndex], both axes in labels order.Dense list of at most 128 rows of at most 128 finite numbers; the operation’s shape constraints also apply.
labelsDistinct label strings defining actual row and predicted column order; score tools require at least one label.Dense list of at most 128 strings, each at most 8,192 UTF-16 code units.
groupsOne group-name string per original label, applied to both matrix axes.Dense list of at most 128 strings, each at most 8,192 UTF-16 code units.
Output fieldInterpretation
resultObject containing the fields below.
result.labelsLabel order for both axes of the returned matrix.
result.matrixReturned nonnegative actual-row/predicted-column table.
json
{
  "input": {
    "matrix": [
      [
        2,
        1
      ],
      [
        0,
        1
      ]
    ],
    "labels": [
      "a",
      "b"
    ],
    "groups": [
      "all",
      "all"
    ]
  },
  "output": {
    "result": {
      "labels": [
        "all"
      ],
      "matrix": [
        [
          4
        ]
      ]
    }
  }
}

Limitations and assumptions

  • The same grouping is applied to both axes; semantic appropriateness of merging classes remains the caller’s choice.
  • Label strings are compared exactly. Confusion values may be nonnegative fractional weights; a count interpretation requires count data. Probability-like score rows use [0,1] entries with sum tolerance 10⁻⁸, without establishing calibration.
  • Every declared top-level input is required and unknown fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
  • Numeric outputs must be finite and within the absolute safe-integer magnitude; exact larger integers use decimal text. Source positions are zero-based UTF-16 offsets and span ends are exclusive unless a different convention is explicitly stated.

Alternative or Complementary methods

Check label coverage and axis order before comparing tables. Use a separate evaluation design for uncertainty, calibration, operating thresholds and the consequences of real-world decisions.

References

  1. Tool behavior and example: Confusion Label Class Collapse — tool.io

Similar or alternative tools

  • Confusion Label Axis Reorder

    Reorder both axes by a complete explicit label permutation without changing counts or label identity.

  • Label Pair Confusion Table

    Build an occurrence-count multiclass confusion table over explicit actual/predicted label observations with a caller-ordered complete label universe; unknown labels reject, no identity coercion.