plot_lift_curve: plot_lift_curve

Description Usage Arguments Value Examples

View source: R/plot_lift_curve.R

Description

Buckets data into groups using predicted value (see prep_num_bin) and finds average predictions and actual in each bucket.

Note: Predictions should be annualised (independent of exposure)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plot_lift_curve(
  actual,
  predicted,
  weight = NULL,
  title = NULL,
  n_bins = 10,
  method = "even_weight",
  use_labels = TRUE,
  mean = 0.5,
  sd = 0.3,
  use_plotly = TRUE
)

Arguments

actual

Array[Numeric] - Values we are aiming to predict.

predicted

Array[Numeric] - Values that we have predicted.

weight

Optional: Array[Numeric] - Weighting of predictions. If NULL even weighting is used

title

Optional: String - Title for the plot

n_bins

numeric - Number of bins to split exposure into

method

string - One of c("even_weight", "gaussian_weight"). If "even_weight" is used the weight (exposure) in each bucket is even If "gaussian_weight" is used the weight look like a normal distribution centered on mean with width sd. The effect of this is to give thinner tails

use_labels

logical - should the bins be numbered or human readable labelled

mean

numeric - Only used when method="gaussian_weight" - value between 0 - 1 for if the bucket with maximum weight is at min or max prediction. Default is 0.5 (middle bucket)

sd

numeric - Only used when method="gaussian_weight" - value between 0.1 - 1 for how thin the distribution tails should be. Low numbers give thin tails

use_plotly

Optional: boolean - If TRUE plotly object is returned else ggplot2 object

Value

plotly/ggplot object of showing lift curve for given predictions

Examples

1
2
plot_lift_curve(actual=1:100, predicted = 1:100 + rnorm(100, mean=0, sd = 10), title="Example Lift Curve")
plot_lift_curve(actual=1:100, predicted = 1:100 + rnorm(100, mean=0, sd = 10), title="Example Lift Curve", method="gaussian_weight")

gloverd2/admr documentation built on Dec. 2, 2020, 11:16 p.m.