Learn R Programming

modeval (version 0.1.3)

suggest_gain: Plot Gain Chart and Lift Chart

Description

suggest_gain Gain and Lift charts are widely used in marketing and related contexts. They indicate the effectiveness of predictive models compared to the results obtained without the predictive model.

Usage

suggest_gain(addTo, outChar, predTag = "pred_test", modelTag = NULL,
  cuts = 51, type = NULL)

Arguments

addTo
Summary list that contains model fits to compare.
outChar
A charactor value of output class name.
predTag
Select prediction results that contains predTag on their name.
modelTag
Select model fits that contains modelTag on their name.
cuts
Integer indicating the number of splits of probability buckets.
type
Plot different type of charts. "Gain" for gain chart. "Lift" for lift chart. "PctAcc" for accumulated event percent. "Pct" for event percent.

Examples

Run this code
## Not run: ------------------------------------
# library(mlbench)
# data(PimaIndiansDiabetes)
# index <- sample(seq_len(nrow(PimaIndiansDiabetes)), 500)
# trainingSet <- PimaIndiansDiabetes[index, ]
# testSet <- PimaIndiansDiabetes[-index, ]
# x <- trainingSet[, -9]
# y <- trainingSet[, 9]
# x_test <- testSet[, -9]
# y_test <- testSet[, 9]
# sSummary <- list()
# sSummary <- add_model(sSummary, x, y)
# sSummary <- add_model(sSummary, x, y, model = c("C5.0Cost", "glmnet"), modelTag = "others")
# sSummary <- add_prob(sSummary, x_test, y_test, outChar = "pos")
# 
# suggest_gain(sSummary, outChar = "pos")
# suggest_gain(sSummary, outChar = "pos", modelTag = "glm|svm", type = "Lift")
# suggest_gain(sSummary, outChar = "pos", modelTag = "glm|svm", type = "PctAcc")
# suggest_gain(sSummary, outChar = "pos", modelTag = "glm|svm", type = "Pct")
# suggest_gain(sSummary, outChar = "pos", modelTag = "glm|svm", type = "Gain")
# suggest_gain(sSummary, outChar = "pos", modelTag = "glm|svm", type = "Gain") + xlim(0, 0.5)
# 
# # vignette("modeval") #check a vignette for further details
## ---------------------------------------------

Run the code above in your browser using DataLab