WOE_custom: Custom Binning Numeric Variables

Description Usage Arguments Value Examples

View source: R/Rprofet.R

Description

Function that bins a numeric variable based on user inputted breaks, plots the information on the new bins, and returns a vector of the newly binned values

Usage

1
WOE_custom(dataset, var, target, breaks, right_bracket = F, color = "#0066CC")

Arguments

dataset

Dataframe containing the target variable and desired numeric variables to be binned.

var

A specific numeric attribute to be binned. Must be specified.

target

A binary target variable. Must be specified.

breaks

A vector of breakpoints for the desired bins. Must be specified.

right_bracket

Logical. Specifying whether the intervals are closed on the right or the left.

color

A hexadecimal value representing a specific color.

Value

A vector containing the newly binned values. Generates three barplots displaying the worth of evidence (WoE), target rate and frequency across all bins. The bars are arranged in an ascending order of WoE.

Examples

1
2
3
4
5
6
7
8
mydata <- ISLR::Default
mydata$default <- ifelse(mydata$default=="Yes", 1, 0) ## target coded with 1, 0
WC_1 <- WOE_custom(dataset=mydata, var="balance", target = "default",
           breaks=seq(0,3000,1000))
levels(factor(WC_1))
WC_2 <- WOE_custom(dataset=mydata, var="income", target = "default",
             breaks=seq(0,75000, 15000))
levels(factor(WC_2))

Rprofet documentation built on April 1, 2020, 5:11 p.m.

Related to WOE_custom in Rprofet...