one_hot_encode: One-hot encode a variable

Description Usage Arguments Value

Description

Given an input data.frame and a target column, one-hot encode the column if the number of unique values is greater than a specified threshold. The original column is dropped. To prevent whitespace appearing in column names, any [:space:] characters are replaced with underscores using gsub.

Usage

1
one_hot_encode(df, col, max_n_cats = Inf, drop_one_col = FALSE)

Arguments

df

A data.frame.

col

The column to be encoded.

max_n_cats

Columns will only be one-hot encoded if they contain this many categories or fewer.

Value

A data.frame.


lewinfox/fast-ai-structured documentation built on May 23, 2019, 5:03 a.m.