Skip to main content

Confusion Matrix

Available

image_classification.confusion_matrix

The dataset-level table of true-label versus predicted-label counts, the basis for the per-class rate metrics.

Contract​

FieldValue
version1.0.0
metric_typepointwise
scorer_contractfull_dataset
directionhigher_is_better
entrypointaip_scorers_image_classification.answered.confusion_matrix
target_kindNone

Required columns​

  • image_id
  • label
  • predictions

Accepted schemas​

[
{
"name": "gdi_image_v1",
"task_types": [
"classification"
]
}
]

Methodology​

  1. Deterministic - no LLM. Uses numpy integer accumulation.
  2. Build the class vocabulary as the sorted union of ground-truth and predicted labels.
  3. For each image, take the top-scoring predicted class.
  4. Increment matrix[true_label, predicted_label]; emit it with the sorted class labels.

Score semantics​

Reported as a labelled matrix artifact rather than a single 0-1 score. A strong diagonal (predicted label equal to true label) is the goal, so larger on-diagonal counts are better. Higher is better.

Worked example​

For labels [cat, dog] with predictions truth->pred of cat->cat, cat->dog, dog->dog, dog->dog, the matrix is [[1, 1], [0, 2]] (rows = true, columns = predicted).

Configuration schema​

{
"description": "Shared image-classification metric configuration.",
"properties": {
"inverted": {
"default": false,
"title": "Inverted",
"type": "boolean",
"x-aip-param-role": "scoring_metadata"
},
"max": {
"default": 1.0,
"title": "Max",
"type": "number",
"x-aip-param-role": "scoring_metadata"
},
"metric_name": {
"default": "image_classification_metric",
"title": "Metric Name",
"type": "string",
"x-aip-param-role": "scoring_metadata"
},
"min": {
"default": 0.0,
"title": "Min",
"type": "number",
"x-aip-param-role": "scoring_metadata"
},
"weight": {
"default": 1.0,
"title": "Weight",
"type": "number",
"x-aip-param-role": "scoring_metadata"
}
},
"title": "InitializationConfig",
"type": "object"
}

Execution​

{
"emits_metric_family": false,
"function_name": null,
"max_concurrency": null,
"processing_kind": "cpu",
"stream_batch_size": null,
"timeout_seconds": 600
}

Complete manifest​

accepts:
- name: gdi_image_v1
task_types:
- classification
config_schema:
description: Shared image-classification metric configuration.
properties:
inverted:
default: false
title: Inverted
type: boolean
x-aip-param-role: scoring_metadata
max:
default: 1.0
title: Max
type: number
x-aip-param-role: scoring_metadata
metric_name:
default: image_classification_metric
title: Metric Name
type: string
x-aip-param-role: scoring_metadata
min:
default: 0.0
title: Min
type: number
x-aip-param-role: scoring_metadata
weight:
default: 1.0
title: Weight
type: number
x-aip-param-role: scoring_metadata
title: InitializationConfig
type: object
dependencies: []
description: Dataset-level true-label by predicted-label confusion matrix.
direction: higher_is_better
display_name: Confusion Matrix
entrypoint: aip_scorers_image_classification.answered.confusion_matrix
execution:
emits_metric_family: false
function_name: null
max_concurrency: null
processing_kind: cpu
stream_batch_size: null
timeout_seconds: 600
kind: metric
manifest_version: '1'
max_prompt_slots: 0
metric_metadata:
methodology:
- Deterministic - no LLM. Uses numpy integer accumulation.
- Build the class vocabulary as the sorted union of ground-truth and predicted labels.
- For each image, take the top-scoring predicted class.
- Increment matrix[true_label, predicted_label]; emit it with the sorted class labels.
score_semantics: Reported as a labelled matrix artifact rather than a single 0-1
score. A strong diagonal (predicted label equal to true label) is the goal, so
larger on-diagonal counts are better. Higher is better.
summary: The dataset-level table of true-label versus predicted-label counts, the
basis for the per-class rate metrics.
worked_example: For labels [cat, dog] with predictions truth->pred of cat->cat,
cat->dog, dog->dog, dog->dog, the matrix is [[1, 1], [0, 2]] (rows = true, columns
= predicted).
metric_type: pointwise
name: image_classification.confusion_matrix
partition_types: []
required_columns:
- image_id
- label
- predictions
required_kinds: []
scorer_contract: full_dataset
target_kind: null
unsupported_trace_shapes: []
version: 1.0.0