binarize {correlationfunnel}R Documentation

Turn data with numeric, categorical features into binary data.

Description

binarize returns the binary data coverted from data in normal (numeric and categorical) format.

Usage

binarize(
  data,
  n_bins = 4,
  thresh_infreq = 0.01,
  name_infreq = "-OTHER",
  one_hot = TRUE
)

Arguments

data

A tibble or data.frame

n_bins

The number of bins to for converting continuous (numeric features) into discrete features (bins)

thresh_infreq

The threshold for converting categorical (character or factor features) into an "Other" Category.

name_infreq

The name for infrequently appearing categories to be lumped into. Set to "-OTHER" by default.

one_hot

If set to TRUE, binarization returns number of new columns = number of levels. If FALSE, binarization returns number of new columns = number of levels - 1 (dummy encoding).

Details

The Goal

The binned format helps correlation analysis to identify non-linear trends between a predictor (binned values) and a response (the target)

What Binarize Does

The binarize() function takes data in a "normal" format and converts to a binary format that is useful as a preparation step before using correlate():

Numeric Features: The "Normal Data" format has numeric features that are continuous values in numeric format (double or integer). The binarize() function converts these to bins (categories) and then discretizes the bins using a one-hot encoding process.

Categorical Features: The "Normal Data" format has categorical features that are character or factor format. The binarize() function converts these to binary features using a one-hot encoding process.

Value

A tbl

Examples

library(dplyr)
library(correlationfunnel)

marketing_campaign_tbl %>%
    select(-ID) %>%
    binarize()



[Package correlationfunnel version 0.2.0 Index]