library(wrapr)
empirical_data <- rbind(
data.frame(
Score = rbeta(1000, shape1 = 3, shape2 = 2),
y = TRUE),
data.frame(
Score = rbeta(1000, shape1 = 5, shape2 = 4),
y = FALSE)
)
unpack[shape1_pos = shape1, shape2_pos = shape2] <-
fit_beta_shapes(empirical_data$Score[empirical_data$y])
shape1_pos
shape2_pos
unpack[shape1_neg = shape1, shape2_neg = shape2] <-
fit_beta_shapes(empirical_data$Score[!empirical_data$y])
shape1_neg
shape2_neg
ideal_roc <- sensitivity_and_specificity_s12p12n(
seq(0, 1, 0.1),
shape1_pos = shape1_pos,
shape1_neg = shape1_neg,
shape2_pos = shape2_pos,
shape2_neg = shape2_neg)
empirical_roc <- build_ROC_curve(
modelPredictions = empirical_data$Score,
yValues = empirical_data$y
)
# # should look very similar
# library(ggplot2)
# ggplot(mapping = aes(x = 1 - Specificity, y = Sensitivity)) +
# geom_line(data = empirical_roc, color='DarkBlue') +
# geom_line(data = ideal_roc, color = 'Orange')
Run the code above in your browser using DataLab