perf_eva: KS, ROC, Lift, PR

Description Usage Arguments Details Value See Also Examples

View source: R/perf.R

Description

perf_eva provides performance evaluations, such as kolmogorov-smirnow(ks), ROC, lift and precision-recall curves, based on provided label and predicted probability values.

Usage

1
2
perf_eva(label, pred, title = NULL, groupnum = NULL, type = c("ks",
  "roc"), show_plot = TRUE, positive = "bad|1", seed = 186)

Arguments

label

Label values, such as 0s and 1s, 0 represent for good and 1 for bad.

pred

Predicted probability or score.

title

Title of plot, default is NULL.

groupnum

The group number when calculating KS. Default NULL, which means the number of sample size.

type

Types of performance plot, such as "ks", "lift", "roc", "pr". Default c("ks", "roc").

show_plot

Logical value, default is TRUE. It means whether to show plot.

positive

Value of positive class, default is "bad|1".

seed

Integer, default is 186. The specify seed is used for random sorting data.

Details

Accuracy = true positive and true negative/total cases

Error rate = false positive and false negative/total cases

TPR, True Positive Rate(Recall or Sensitivity) = true positive/total actual positive

PPV, Positive Predicted Value(Precision) = true positive/total predicted positive

TNR, True Negative Rate(Specificity) = true negative/total actual negative = 1-FPR

NPV, Negative Predicted Value = true negative/total predicted negative

Value

ks, roc, lift, pr

See Also

perf_psi

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
## Not run: 
# load germancredit data
data("germancredit")

# filter variable via missing rate, iv, identical value rate
dt_sel = var_filter(germancredit, "creditability")

# woe binning ------
bins = woebin(dt_sel, "creditability")
dt_woe = woebin_ply(dt_sel, bins)

# glm ------
m1 = glm( creditability ~ ., family = binomial(), data = dt_woe)
# summary(m1)

# Select a formula-based model by AIC
m_step = step(m1, direction="both", trace=FALSE)
m2 = eval(m_step$call)
# summary(m2)

# predicted proability
dt_pred = predict(m2, type='response', dt_woe)

# performance ------
# Example I # only ks & auc values
perf_eva(dt_woe$creditability, dt_pred, show_plot=FALSE)

# Example II # ks & roc plot
perf_eva(dt_woe$creditability, dt_pred)

# Example III # ks, lift, roc & pr plot
perf_eva(dt_woe$creditability, dt_pred, type = c("ks","lift","roc","pr"))

## End(Not run)

scorecard documentation built on Sept. 11, 2018, 9:03 a.m.