Turns a plain ground-truth changepoint set — the kind
cpt_metrics() takes — into labelled regions, so one
annotation can drive both the metric and the supervised machinery. Each
true changepoint becomes a "one_change" region of width
2 * margin + 1, and the stretches between them become
"no_change" regions.
Arguments
- truth
Integer vector of true changepoint positions.
- n
Series length.
- margin
Half-width of the positive regions. Defaults to
5, matchingcpt_metrics()'s default tolerance.- negatives
Add the
"no_change"regions between the positives? Defaults toTRUE; without them a detector is never penalised for a false positive.- series
Optional series identifier.
Examples
as_cpt_labels(c(50, 120), n = 200)
#> # A tibble: 5 × 5
#> label_id series start end change
#> <int> <chr> <int> <int> <chr>
#> 1 3 NA 1 44 no_change
#> 2 1 NA 45 55 one_change
#> 3 4 NA 56 114 no_change
#> 4 2 NA 115 125 one_change
#> 5 5 NA 126 199 no_change
