Skip to main content

ClassificationSpec

ClassificationSpec()

One label for a whole image, scored by how well the answers can be ranked.

The task crops() has been cutting objects out for and handing them to nothing, and the one explaining a model needs: a saliency map explains this answer, and until now there was no per-image answer to explain.

A contracting path, pooled, with one dense layer on top - ours or any of timm’s, chosen by encoder, which is why this is the one task with no architecture field: there is nothing after the pooling for a second name to describe.

What is worth knowing before writing one, because it decides what the numbers mean. The default metric is auc rather than accuracy, measured rather than preferred: on 40000 images at a prevalence of 3%, with the model’s own probabilities as the truth so that only its discrimination varies, accuracy spans 0.0100 where the AUC spans 0.4631 and is not monotone - a model with no signal at all scores above two models that have one. Balanced accuracy and F1 do not rescue it either, because a calibrated model at that prevalence never crosses the threshold and everything read off the hard prediction sees the same all-negative answer.

The same arithmetic decides the split. A random 70/15/15 of 100 images at 3% prevalence leaves some part with none of the rare class 91% of the time, so split is stratified for this task and a class with fewer examples than there are parts is refused by name. ClassificationEngine.balance() reports the prevalence rather than leaving it to be discovered from a score that looks fine.

Methods

Name Description
a_set_of_labels_rules_out_the_metric_that_rewards_a_collapse accuracy is refused when labels_from made each class its own question.
nothing_watches_a_validation_number_that_will_not_arrive A callback cannot wait for val_loss in a run that has no validation set.

a_set_of_labels_rules_out_the_metric_that_rewards_a_collapse

ClassificationSpec.a_set_of_labels_rules_out_the_metric_that_rewards_a_collapse(
)

accuracy is refused when labels_from made each class its own question.

Measured before the choice was put up rather than after. On 4000 images with findings at 10%, 5%, 3% and 2% - a chest film’s profile, one draw of the truth, and models whose ordering is degraded by noise rather than shrunk:

quality        exact   per-class   balanced   macro f1   macro auc
1.00          0.8353      0.9570     0.5742     0.2339      0.9029
0.50          0.8023      0.9477     0.5433     0.1444      0.8041
0.00          0.7650      0.9370     0.4984     0.0184      0.4834
all-negative  0.8137      0.9507     0.5000     0.0000      0.5000

The disqualifying reading is the row’s position rather than the size of a gap. A model answering no to everything scores above the model holding half the available signal on both readings of accuracy - 0.8137 against 0.8023 exact, 0.9507 against 0.9477 per class - while balanced_accuracy, f1 and auc all put it below every model with any signal at all. A number that rewards giving up cannot be what a monitor watches.

This is a different mechanism from the single-label finding and the argument does not carry over, which is worth saying because reusing it would have been easy: there, accuracy is nearly flat and non-monotone in the signal. Here both readings are monotone on two seeds, and what breaks them is the comparison against a collapse, which is not a point on that curve - an all-negative answer is not a noisy model, it is a confident one.

Read off supports_multilabel on the metric’s own specification rather than a list here, the way the losses’ admissibility is read off continuous and needs_extent. build_classification_metric refuses the same thing one layer down, for a caller that assembled a metric list without a specification - a second line of the wall rather than a second copy of it.

And the matching loss refusal is deliberately absent, because it would be unreachable. Measured off the flags: the two losses a label admits - cce and focal, the ones with neither needs_extent nor continuous - both carry supports_multilabel=True, so no admissible loss can fail that test today. build_loss(multilabel=True) refuses by name if a third one ever arrives, which is the mechanism already there; a validator here would be a guard for a state nothing can produce, and this file deleted one of those an hour earlier for the same reason.

nothing_watches_a_validation_number_that_will_not_arrive

ClassificationSpec.nothing_watches_a_validation_number_that_will_not_arrive()

A callback cannot wait for val_loss in a run that has no validation set.