merge_category {creditmodel}R Documentation

Merge Category

Description

merge_category is for merging category of nominal variables which number of categories is more than m or percent of samples in any categories is less than p.

Usage

merge_category(dat, char_list = NULL, ex_cols = NULL, m = 10, note = TRUE)

Arguments

dat

A data frame with x and target.

char_list

The list of charecteristic variables that need to merge categories, Default is NULL. In case of NULL,merge categories for all variables of string type.

ex_cols

A list of excluded variables. Default is NULL.

m

The minimum number of categories.

note

Logical, outputs info. Default is TRUE.

Value

A data.frame with merged category variables.

Examples

#merge_catagory
dat =  merge_category(lendingclub,ex_cols = "id$|_d$")
char_list = get_names(dat = dat,types = c('factor', 'character'),
ex_cols = "id$|_d$", get_ex = FALSE)
str(dat[,char_list])

[Package creditmodel version 1.3.0 Index]