Skip to main content

Score every case separately

Description

evaluate() gives one row per model: one number for a whole set. This gives one row per case - each image, or each patient when group_by is set - because one number hides the distribution, and the distribution is usually the finding. A model averaging Dice 0.86 that scores 0.1 on three patients has a failure mode, and the mean is where it hides.

Usage

evaluate_cases(object, ...)

## S3 method for class 'platypus_fit'
evaluate_cases(
  object,
  model = NULL,
  split = "validation",
  group_by = NULL,
  at = NULL,
  decode = NULL,
  ...
)

## S3 method for class 'platypus_cases'
summary(object, ...)

Arguments

object A platypus_cases from evaluate_cases().
… Must be empty. Accepted because the generic has it, and checked rather than ignored so that a misspelt argument is refused instead of changing the answer.
model Which model, by the name in the specification. Defaults to the first.
split Which data to score on.
group_by A pattern picking a group out of each case’s name, as in split_dataset(). With it, the rows are patients rather than slices: a patient’s slices are pooled into one score, the way a volume would be.
at Which grid to score on, as in evaluate(). Unset is the model’s own load_shape; “source” reads each truth as stored and scores the prediction there, which is the only form in which rows from two models - or from two runs with different target_spacing - mean the same thing.
decode Which decoding’s cases to score, by the name used in the model’s decode list. Unset takes the model’s first, which is the engine’s own default. Only an instance fit decodes anything, so naming it on any other task is refused rather than ignored - and evaluate() is where the per-decoding means are, one row each.

Details

summary() on the result gives the distribution: mean, standard deviation, median, range, and which case scored worst.

Tiled models are scored on the whole image, not on tiles. Overlaps are accumulated across a case’s tiles and the metric applied once, which is that image’s score exactly; averaging the tiles’ scores would be a different number, and unkind to any case whose object happens to straddle a boundary.

Value

A data frame with one row per case, of class platypus_cases.

See Also

split_dataset() for keeping a patient out of two sets in the first place.

Examples

library("rplatypus")

cases <- evaluate_cases(fit)
summary(cases)
head(cases[order(cases$dice), ])          # the ones worth looking at

evaluate_cases(fit, group_by = "^(patient\\\\d+)_")

# On the grid the files are on, which is what makes two models comparable.
evaluate_cases(fit, at = "source")