scorecard2: Creating a Scorecard

Description Usage Arguments Value See Also Examples

View source: R/scorecard.R

Description

scorecard2 creates a scorecard based on the results from woebin. It has the same function of scorecard, but without model object input and provided adjustment for oversampling.

Usage

1
2
3
scorecard2(bins, dt, y, x = NULL, badprob_pop = NULL, points0 = 600,
  odds0 = 1/19, pdo = 50, basepoints_eq0 = FALSE, digits = 0,
  return_prob = FALSE, positive = "bad|1", ...)

Arguments

bins

Binning information generated from woebin function.

dt

A data frame with both x (predictor/feature) and y (response/label) variables.

y

Name of y variable.

x

Name of x variables. If it is NULL, then all variables in bins are used. Defaults to NULL.

badprob_pop

Bad probability of population. Accepted range: 0-1, default to NULL. If it is not NULL, the model will adjust for oversampling.

points0

Target points, default 600.

odds0

Target odds, default 1/19. Odds = p/(1-p).

pdo

Points to Double the Odds, default 50.

basepoints_eq0

Logical, defaults to FALSE. If it is TRUE, the basepoints will equally distribute to each variable.

digits

The number of digits after the decimal point for points calculation. Default 0.

return_prob

Logical, defaults to FALSE. If it is TRUE, the predict probability will also return.

positive

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

...

Additional parameters.

Value

A list of scorecard data frames

See Also

scorecard scorecard_ply

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
36
37
38
# 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 ------
m = glm(creditability ~ ., family = binomial(), data = dt_woe)
# summary(m)

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

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

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

# scorecard
# Example I # creat a scorecard
card = scorecard(bins, m)
card2 = scorecard2(bins=bins, dt=germancredit, y='creditability',
  x= sub('_woe', '', names(coef(m))[-1]))

# credit score
# Example I # only total score
score1 = scorecard_ply(germancredit, card)

# Example II # credit score for both total and each variable
score2 = scorecard_ply(germancredit, card, only_total_score = FALSE)

scorecard documentation built on Aug. 30, 2020, 5:06 p.m.