After wrapping up the function batch_woe() today with the purpose to allow users to apply WoE transformations to many independent variables simultaneously, I have completed the development of major functions in the MOB package that can be usable for the model development in a production setting.
The function batch_woe() basically is the wrapper around cal_woe() and has two input parameters. The “data” parameter is the data frame that we would deploy binning outcomes and the “slst” parameter is the list of multiple binning specification tables that is either the direct output from the function batch_bin or created manually by combining outputs from multiple binning functions.
There are also two components in the output of batch_woe(), a list of PSI tables for transformed variables and a data frame with a row index and all transformed variables. The default printout is a PSI summation of all input variables to be transformed. As shown below, all PSI values are below 0.1 and therefore none is concerning.
binout <- batch_bin(df, 1) woeout <- batch_woe(df[sample(seq(nrow(df)), 2000, replace = T), ], binout$BinLst) woeout # tot_derog tot_tr age_oldest_tr tot_open_tr tot_rev_tr tot_rev_debt ... # psi 0.0027 0.0044 0.0144 0.0011 3e-04 0.0013 ... str(woeout, max.level = 1) # List of 2 # $ psi:List of 11 # $ df :'data.frame': 2000 obs. of 12 variables: # - attr(*, "class")= chr "psiSummary" head(woeout$df, 1) # idx_ woe.tot_derog woe.tot_tr woe.age_oldest_tr woe.tot_open_tr woe.tot_rev_tr ... # 1 -0.3811 -0.0215 -0.5356 -0.0722 -0.1012 ...
All source codes of the MOB package are available on https://github.com/statcompute/MonotonicBinning and free (as free beer) to download and distribute.