Description Usage Arguments Value See Also Examples
woe()
produces a weight of evidence table, evaluating
x
as the independent variable and y
as the dependent variable.
It depends on an S3 generic function bin for binning the values of
x
. Character, factor and logical vectors for x
are all treated
as categorical. Numeric vectors are treated as continuous (numeric) as long
as they have more distinct values than the number of bins (numBins
)
specified, otherwise they are treated as categorical. Integer vectors are
handled as numeric vectors.
1 |
x |
character, factor, logical or numeric vector (independent variable) |
y |
logical, integer or numeric vector that is coercable to numeric with unique values of 0 and 1 (dependent variable) |
... |
further arguments passed to bin |
A data frame with class "mt_woe
" summarizing the weight of
evidence and information value calculations for an independent variable
x
with respect to a binary dependent variable y
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # factor
woe(iris$Species, round(runif(nrow(iris))))
# numeric - equally spaced vs. equally sized bins
x <- rnorm(1000, mean = 100, sd = 5)
y <- round(runif(1000))
woe(x, y)
woe(x, y, equalBinSize = TRUE)
# evaluate all columns in a data frame
wl <- lapply(mtcars, woe, y = round(runif(nrow(mtcars))))
names(wl)
wl$mpg
# create table of total info values
iv <- unlist(lapply(wl, infoValue))
data.frame(
Variable = names(iv),
InformationValue = as.numeric(iv),
stringsAsFactors = FALSE
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.