Skip to content

Commit

Permalink
add example for numeric calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Apr 24, 2024
1 parent fbc9fbe commit cfe9455
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
23 changes: 23 additions & 0 deletions R/adjust-numeric-calibration.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
#' @param x A [container()].
#' @param calibrator A pre-trained calibration method from the \pkg{probably}
#' package, such as [probably::cal_estimate_linear()].
#' @examples
#' library(modeldata)
#' library(probably)
#' library(tibble)
#'
#' # create example data
#' set.seed(1)
#' dat <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100))
#'
#' dat
#'
#' # calibrate numeric predictions
#' reg_cal <- cal_estimate_linear(dat, truth = y, estimate = y_pred)
#'
#' # specify calibration
#' reg_ctr <-
#' container(mode = "regression") %>%
#' adjust_numeric_calibration(reg_cal)
#'
#' # "train" container
#' reg_ctr_trained <- fit(reg_ctr, dat, outcome = y, estimate = y_pred)
#'
#' predict(reg_ctr, dat)
#' @export
adjust_numeric_calibration <- function(x, calibrator) {
check_container(x)
Expand Down
24 changes: 24 additions & 0 deletions man/adjust_numeric_calibration.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cfe9455

Please sign in to comment.