Counts label errors: a positive region with no changepoint is a false
negative, a negative region with one is a false positive, and a
"one_change" region with two or more is a false positive as well.
This is the accuracy measure supervised changepoint detection is built on,
and, unlike an information criterion, it is defined by what the expert
asserted rather than by a model assumption.
Arguments
- object
A
ggcptobject, or an integer vector of changepoint positions.- labels
A
cpt_labelstibble (or anything withstart/end/changecolumns).- x
A
cpt_label_errorobject (forprint()).- ...
Ignored.
Value
A tibble with one row per label: label_id,
series (the label set's series identifier, NA for a
single unnamed series), start, end, change,
n_changes (how many detections fell inside), status ("correct", "false_positive" or
"false_negative"), carrying the totals in an errors
attribute and printing them. An empty label set gives a zero-row
tibble with the same columns.
Examples
set.seed(2026)
fit <- cpt_detect(c(rnorm(50), rnorm(50, 4)), method = "pelt")
labs <- cpt_labels(c(40, 70), c(60, 95), c("one_change", "no_change"))
cpt_label_error(fit, labs)
#> cpt_label_error (2 label(s))
#> correct: 2 false positives: 0 false negatives: 0
#> total label errors: 0
#>
#> # A tibble: 2 × 7
#> label_id series start end change n_changes status
#> <int> <chr> <int> <int> <chr> <int> <chr>
#> 1 1 NA 40 60 one_change 1 correct
#> 2 2 NA 70 95 no_change 0 correct
