qini: Computes the Qini Coefficient Q

Description Usage Arguments Details Value Author(s) References Examples

View source: R/qini.R

Description

This function computes the Qini coefficient from a performance object (as created by the function performance).

Usage

1
2
## S3 method for class 'performance'
qini(x, direction = 1, plotit = TRUE, ...)

Arguments

x

an object of class performance.

direction

possible values are 1 (default) if the objective is to maximize the difference in the response for Treatment minus Control, and 2 for Control minus Treatment.

plotit

plot the incremental gains from the fitted model?

...

additional arguments passed to plot.

Details

Qini coefficients represent a natural generalizations of the Gini coefficient to the case of uplift. Qini is defined as the area between the actual incremental gains curve from the fitted model and the area under the diagonal corresponding to random targeting. See the references for details.

Value

A list with the following components

Qini

the Qini coefficient as defined above.

inc.gains

the incremental gain values from the fitted model.

random.inc.gains

the random incremental gains.

Author(s)

Leo Guelman <leo.guelman@gmail.com>

References

Radcliffe, N. and Surry, P. (2011). Real-World Uplift Modelling with Significance-Based Uplift Trees. Portrait Technical Report, TR-2011-1.

Radcliffe, N. (2007). Using control groups to target on predicted lift: Building and assessing uplift models. Direct Marketing Analytics Journal, An Annual Publication from the Direct Marketing Association Analytics Council, pages 14-21.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
library(uplift)

### simulate data for uplift modeling

set.seed(123)
dd <- sim_pte(n = 1000, p = 20, rho = 0, sigma =  sqrt(2), beta.den = 4)
dd$treat <- ifelse(dd$treat == 1, 1, 0) 

### fit uplift random forest

fit1 <- upliftRF(y ~ X1 + X2 + X3 + X4 + X5 + X6 + trt(treat),
                 data = dd, 
                 mtry = 3,
                 ntree = 100, 
                 split_method = "KL",
                 minsplit = 200, # need small trees as there is strong uplift effects in the data
                 verbose = TRUE)
print(fit1)
summary(fit1)

### predict on new data 

dd_new <- sim_pte(n = 2000, p = 20, rho = 0, sigma =  sqrt(2), beta.den = 4)
dd_new$treat <- ifelse(dd_new$treat == 1, 1, 0)  

pred <- predict(fit1, dd_new)

### evaluate model performance

perf <- performance(pred[, 1], pred[, 2], dd_new$y, dd_new$treat, direction = 1)

### compute Qini coefficient

Q <- qini(perf, plotit = TRUE)
Q

Example output

Loading required package: RItools
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

Loading required package: MASS
Loading required package: coin
Loading required package: survival
Loading required package: tables
Loading required package: Hmisc
Loading required package: lattice
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, round.POSIXt, trunc.POSIXt, units

Loading required package: penalized
Welcome to penalized. For extended examples, see vignette("penalized").
uplift: status messages enabled; set "verbose" to false to disable
upliftRF: starting. Wed Dec 13 08:35:06 2017 
10 out of 100 trees so far...
20 out of 100 trees so far...
30 out of 100 trees so far...
40 out of 100 trees so far...
50 out of 100 trees so far...
60 out of 100 trees so far...
70 out of 100 trees so far...
80 out of 100 trees so far...
90 out of 100 trees so far...
Call:
upliftRF(formula = y ~ X1 + X2 + X3 + X4 + X5 + X6 + trt(treat), 
    data = dd, mtry = 3, ntree = 100, split_method = "KL", minsplit = 200, 
    verbose = TRUE)

Uplift random forest
Number of trees: 100
No. of variables tried at each split: 3
Split method: KL
$call
upliftRF(formula = y ~ X1 + X2 + X3 + X4 + X5 + X6 + trt(treat), 
    data = dd, mtry = 3, ntree = 100, split_method = "KL", minsplit = 200, 
    verbose = TRUE)

$importance
  var  rel.imp
1  X1 39.97286
2  X2 25.07182
3  X4 18.37845
4  X3 16.57687

$ntree
[1] 100

$mtry
[1] 3

$split_method
[1] "KL"

attr(,"class")
[1] "summary.upliftRF"
$Qini
[1] 0.104765

$inc.gains
 [1] 0.068 0.117 0.140 0.176 0.185 0.156 0.139 0.117 0.086 0.023

$random.inc.gains
 [1] 0.0023 0.0046 0.0069 0.0092 0.0115 0.0138 0.0161 0.0184 0.0207 0.0230

uplift documentation built on May 2, 2019, 9:32 a.m.