perf.decile: Check model performance based on predicated and actual rates

Description Usage Arguments Value Examples

Description

perf.decile takes the actual status (actual), and the predicted probability (pred) as inputs, divided the data into 10 decile dependent on the ranking of the predicted values, and calculate the average predicted and actual rates in each decile.

Usage

1
perf.decile(actual, pred, plot = TRUE, add.legend = TRUE)

Arguments

actual

A vector containing the actual status for each record

pred

The predicted probability for each record

plot

Whether to show the ggplot figure

add.legent

Whether to add a legend for the decile color

Value

The predicted and actual rates in each decile and a ggplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data <- rpart::stagec
data <- data[sample(nrow(data), 10000, replace = TRUE), ]
data <- na.omit(data)

ind.train <- caret::createDataPartition(data$pgstat, p = .7, list = FALSE)
dt.train <- data[ind.train, ]
dt.test <- data[-ind.train, ]
mod <- glm(pgstat ~ ., dt.train, family=binomial(link='logit'))

pred.test <- predict(mod, newdata = dt.test, type = 'response')
perf.decile(actual = dt.test$pgstat, pred = pred.test)

JianhuaHuang/streamlineR documentation built on May 7, 2019, 10:40 a.m.