library(ggplot2)
n = 1000
df = data.frame(actual = sample(c(FALSE, TRUE), n, replace = TRUE),
runif = runif(n))
df[["fitted"]] = runif(n) ^ ifelse(df[["actual"]] == 1, 0.5, 2)
density_plot(df, "fitted", "actual")
lift_plot(df, "fitted", "actual")
lift_plot(df, "fitted", "actual") + scale_y_log10()
lift_plot(df, "runif", "actual", size_line = 0.5)
# \donttest{
library(dplyr, warn.conflicts = FALSE)
lift_plot(df, "fitted", "actual", "sample(c(1, 2), n(), TRUE)")
lift_plot(df, "fitted", "actual",
"sample(c(1, 2), n(), TRUE)",
"sample(c(3, 4), n(), TRUE)")
lift_plot(df, "fitted", "actual",
"sample(c(1, 2), n(), TRUE)",
"sample(c(3, 4), n(), TRUE)",
"sample(c(5, 6), n(), TRUE)")
# }
Run the code above in your browser using DataLab