# lift

##### Lift Plot

For classification models, this function creates a 'lift plot' that describes how well a model ranks samples for one class

- Keywords
- hplot

##### Usage

`lift(x, ...)`## S3 method for class 'formula':
lift(x, data = NULL, class = NULL,
subset = TRUE, lattice.options = NULL, labels = NULL,
...)

## S3 method for class 'lift':
xyplot(x, data, ...)

##### Arguments

- x
- a
`lattice`

formula (see`xyplot`

for 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 - data
- For
`lift.formula`

, a data frame (or more precisely, anything that is a valid`envir`

argument in`eval`

, e.g., a list or an environment) containing values for any variables in the formula, as well as`groups`

a - class
- a character string for the class of interest
- subset
- An expression that evaluates to a logical or integer indexing vector. It is evaluated in
`data`

. Only the resulting rows of`data`

are used for the plot. - lattice.options
- A list that could be supplied to
`lattice.options`

- labels
- A named list of labels for keys. The list should have an element for each term on the right-hand side of the formula and the names should match the names of the models.
- ...
- options to pass through to
`xyplot`

or the panel function (not used in`lift.formula`

).

##### Details

`lift.formula`

is used to process the data and `xyplot.lift`

is used to create the plot.

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
- Each unque value of the score is treated as a cut point
- The number of samples with true results equal to
`class`

are determined - The lift is calculated as the ratio of the percentage of samples in each split corresponding to
`class`

over the same percentage in the entire data set

`lift`

produces 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 `panel.lift2`

).

The following elements are set by default in the plot but can be changed by passing new values into `xyplot.lift`

: `xlab = "% Samples Tested"`

, `ylab = "% Samples Found"`

, `type = "S"`

, `ylim = extendrange(c(0, 100))`

and `xlim = extendrange(c(0, 100))`

.

##### Value

`lift.formula`

returns a list with elements:data the data used for plotting cuts the number of cuts class the event class probNames the names of the model probabilities pct the baseline event rate `xyplot.lift`

returns alattice object

##### See Also

##### Examples

```
set.seed(1)
simulated <- data.frame(obs = factor(rep(letters[1:2], each = 100)),
perfect = sort(runif(200), decreasing = TRUE),
random = runif(200))
lift1 <- lift(obs ~ random, data = simulated)
lift1
xyplot(lift1)
lift2 <- lift(obs ~ random + perfect, data = simulated)
lift2
xyplot(lift2, auto.key = list(columns = 2))
```

*Documentation reproduced from package caret, version 5.15-044, License: GPL-2*