Skip to contents

Bins predicted probabilities and computes observed frequencies within each bin. Useful for calibration plots of binary classifiers.

Usage

calibration_df(truth, prob, n_bins = 10L)

Arguments

truth

numeric vector (0/1 or TRUE/FALSE).

prob

numeric vector of predicted probabilities.

n_bins

integer, number of bins (default 10).

Value

A data.frame with columns bin_mid, obs_freq, mean_pred, n.

Examples

calibration_df(
  truth = c(0, 0, 1, 1),
  prob = c(0.1, 0.3, 0.7, 0.9),
  n_bins = 2
)
#>   bin_mid obs_freq mean_pred n
#> 1    0.25        0       0.2 2
#> 2    0.75        1       0.8 2