Skip to main content

Per-Class Specificity

Available

image_classification.per_class_specificity

Specificity computed separately for each class label, emitted as a per-class breakdown alongside the macro-average score.

Contract​

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

Required columns​

  • image_id
  • label
  • predictions

Accepted schemas​

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

Methodology​

  1. Deterministic - no LLM. Derived from the confusion matrix (numpy counts).
  2. Compute per-class specificity = TN / (TN + FP) for every class, with undefined rates rendered as 0.0.
  3. Emit the per-class specificities as an artifact keyed by class name.
  4. Report the macro-average specificity as the scalar score.

Score semantics​

The scalar score is the macro-average specificity (0-1); the artifact reports each class's specificity by name. A high score means the model rarely over-assigns each class. Higher is better.

Worked example​

Confusion matrix [[1, 1], [0, 2]] emits {cat: 1.0, dog: 0.5} and a scalar macro-average of 0.75.

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: Specificity for each class label, emitted as a per-class score artifact.
direction: higher_is_better
display_name: Per-Class Specificity
entrypoint: aip_scorers_image_classification.answered.per_class_specificity
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. Derived from the confusion matrix (numpy counts).
- Compute per-class specificity = TN / (TN + FP) for every class, with undefined
rates rendered as 0.0.
- Emit the per-class specificities as an artifact keyed by class name.
- Report the macro-average specificity as the scalar score.
score_semantics: The scalar score is the macro-average specificity (0-1); the artifact
reports each class's specificity by name. A high score means the model rarely
over-assigns each class. Higher is better.
summary: Specificity computed separately for each class label, emitted as a per-class
breakdown alongside the macro-average score.
worked_example: 'Confusion matrix [[1, 1], [0, 2]] emits {cat: 1.0, dog: 0.5} and
a scalar macro-average of 0.75.'
metric_type: pointwise
name: image_classification.per_class_specificity
partition_types: []
required_columns:
- image_id
- label
- predictions
required_kinds: []
scorer_contract: full_dataset
target_kind: null
unsupported_trace_shapes: []
version: 1.0.0