Sensitivity plus specificity minus one, at the threshold that maximises it. This is the metric
species distribution modelling reports. The shipped presence-absence response is scored by
roc_auc() instead, which chooses no threshold, and TSS is reported beside it.
Details
A cut may only fall between distinct predictions: units sharing a prediction are decided
together, so the same score comes back whatever order they arrived in. A cell holding only
presences or only absences has no skill to measure and returns NA rather than a number.
The threshold is chosen on the same units the score is then read on, which is how the metric is
defined in the literature and how it is defined here, and it inflates the level where presences
are thin. tss_inflation() measures that inflation for a given design. How large it is depends
on how a model's predictions are distributed as well as on the design, so two models of equal
skill scored on the same cells can carry different inflations, and a paired difference in TSS is
not free of it. Given a threshold learned elsewhere, the score
is read at that cut instead, which is what select_grain() reports under threshold = with a
cut learned on the inner folds.