calibrate: Calibrate predicted probabilities

View source: R/calibrate.R

calibrateR Documentation

Calibrate predicted probabilities

Description

Calibrate predicted probabilities

Usage

calibrate(
  true.labels,
  predicted.prob,
  pos.class = NULL,
  alg = "isotonic",
  learn.params = list(),
  verbose = TRUE
)

Arguments

true.labels

Factor with true class labels.

predicted.prob

Numeric vector with predicted probabilities.

pos.class

Integer: Index of the positive class.

alg

Character: Algorithm to use to train calibration model. See select_learn().

learn.params

List: List of parameters to pass to the learning algorithm

verbose

Logical: If TRUE, print messages to the console

Value

Trained calibration model. Use ⁠$fitted.values⁠ to get calibrated input probabilities; use predict(mod, newdata = newdata, type = "response") to calibrate other estimated probabilities.

Author(s)

EDG

Examples

## Not run: 
data("segment_naive_bayes", package = "probably")

# Plot the calibration curve of the original predictions
dplot3_calibration(
  true.labels = segment_naive_bayes$Class,
  predicted.prob = segment_naive_bayes$.pred_poor,
  pos.class = 2
)

# Plot the calibration curve of the calibrated predictions
dplot3_calibration(
  true.labels = segment_naive_bayes$Class,
  predicted.prob = calibrate(
    segment_naive_bayes$Class,
    segment_naive_bayes$.pred_poor
  )$fitted.values,
  pos.class = 2
)

## End(Not run)

egenn/rtemis documentation built on Dec. 17, 2024, 6:16 p.m.