Specificity
image_classification.specificity
The average one-vs-rest specificity across classes - how well the model rejects images that do not belong to each class.
Contract
| Field | Value |
|---|---|
version | 1.0.0 |
metric_type | pointwise |
scorer_contract | full_dataset |
direction | higher_is_better |
entrypoint | aip_scorers_image_classification.answered.specificity |
target_kind | None |
Required columns
image_idlabelpredictions
Accepted schemas
[
{
"name": "gdi_image_v1",
"task_types": [
"classification"
]
}
]
Methodology
- Deterministic - no LLM. Derived from the confusion matrix (numpy counts).
- For each class, read one-vs-rest counts: true negatives and false positives.
- Compute per-class specificity = TN / (TN + FP).
- Macro-average across classes, skipping classes whose specificity is undefined.
Score semantics
Scores range 0-1, the macro-average of per-class specificity. A high score means few false positives per class; a low score means the model over-assigns classes. Higher is better.
Worked example
Confusion matrix [[1, 1], [0, 2]] gives specificity(cat) = 2/2 and specificity(dog) = 1/2 -> macro-average 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": "image_classification.confusion_matrix",
"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: Mean one-vs-rest specificity across classes.
direction: higher_is_better
display_name: Specificity
entrypoint: aip_scorers_image_classification.answered.specificity
execution:
emits_metric_family: false
function_name: image_classification.confusion_matrix
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).
- 'For each class, read one-vs-rest counts: true negatives and false positives.'
- Compute per-class specificity = TN / (TN + FP).
- Macro-average across classes, skipping classes whose specificity is undefined.
score_semantics: Scores range 0-1, the macro-average of per-class specificity. A
high score means few false positives per class; a low score means the model over-assigns
classes. Higher is better.
summary: The average one-vs-rest specificity across classes - how well the model
rejects images that do not belong to each class.
worked_example: Confusion matrix [[1, 1], [0, 2]] gives specificity(cat) = 2/2 and
specificity(dog) = 1/2 -> macro-average 0.75.
metric_type: pointwise
name: image_classification.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