dplot3_calibration: Draw calibration plot

View source: R/dplot3_calibration.R

dplot3_calibrationR Documentation

Draw calibration plot

Description

Draw calibration plot

Usage

dplot3_calibration(
  true.labels,
  predicted.prob,
  n.bins = 10,
  bin.method = c("quantile", "equidistant"),
  pos.class = NULL,
  main = NULL,
  subtitle = NULL,
  xlab = "Mean predicted probability",
  ylab = "Empirical risk",
  show.marginal.x = TRUE,
  marginal.x.y = -0.02,
  marginal.col = NULL,
  marginal.size = 10,
  mode = "markers+lines",
  show.brier = TRUE,
  theme = rtTheme,
  filename = NULL,
  ...
)

Arguments

true.labels

Factor or list of factors with true class labels

predicted.prob

Numeric vector or list of numeric vectors with predicted probabilities

n.bins

Integer: Number of windows to split the data into

bin.method

Character: "quantile" or "equidistant": Method to bin the estimated probabilities.

pos.class

Integer: Index of the positive class

main

Character: Main title

subtitle

Character: Subtitle, placed bottom right of plot

xlab

Character: x-axis label

ylab

Character: y-axis label

show.marginal.x

Logical: Add marginal plot of distribution of estimated probabilities

marginal.x.y

Numeric: Y position of marginal markers on x-axis

marginal.col

Color for marginal markers

marginal.size

Numeric: Size of marginal markers

mode

Character: "lines", "markers", "lines+markers": How to plot.

show.brier

Logical: If TRUE, add Brier scores to trace names.

theme

List or Character: Either the output of a ⁠theme_*()⁠ function or the name of a theme. Use themes() to get available theme names. Theme functions are of the form ⁠theme_<name>⁠.

filename

Character: Path to save output.

...

Additional arguments passed to dplot3_xy

Author(s)

EDG

Examples

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

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

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

## End(Not run)

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