For classification models, this function creates a 'lift plot' that describes how well a model ranks samples for one class
lift(x, data = NULL, class = NULL, cuts = 11, subset = TRUE, lattice.options = NULL, ylabel = "% Samples Found", xlabel = "% Samples Tested", ...)
xyplotfor syntax) where the left-hand side of the formula is a factor class variable of the observed outcome and the right-hand side specifies one or model
- a data frame (or more precisely, anything that is a valid
veal, e.g., a list or an environment) containing values for any variables in the formula, as well as
- a character string for the class of interest
- the number of splits of the data are used to create the plot.
- An expression that evaluates to a logical or integer indexing vector. It is evaluated in
data. Only the resulting rows of
dataare used for the plot.
- A list that could be supplied to
- a text label for the x axis
- a text label for the y axis
- options to pass through to
xyplotor the panel function
To construct the lift plot, the following steps are used for each model:
- The data are ordered by the numeric model prediction used on the right-hand side of the model formula
- The data are split into
cuts - 1roughly equal groups
- the number of samples with true results equal to
- the lift is calculated as the ratio of the percentage of samples in each split corresponding to
classover the same percentage in the entire data set
liftproduces a plot of the cumulative lift values by the percentage of samples evaluated.
This implementation uses the
xyplot, so plot elements can be changed via panel functions,
trellis.par.set or other means.
lift uses the panel function
panel.lift2 by default, but it can be changes using
update.trellis (see the examples in
set.seed(1) simulated <- data.frame(obs = factor(rep(letters[1:2], each = 100)), perfect = sort(runif(200), decreasing = TRUE), random = runif(200)) lift(obs ~ random, data = simulated) lift(obs ~ random, data = simulated, type = c("p", "l")) lift(obs ~ random + perfect, data = simulated, type = c("p", "l"), auto.key = list(columns = 2))