build_bins {dataPreparation} | R Documentation |
Compute bins
Description
Compute bins for discretization of numeric variable (either equal_width or equal_fred).
Usage
build_bins(
data_set,
cols = "auto",
n_bins = 10,
type = "equal_width",
verbose = TRUE
)
Arguments
data_set |
Matrix, data.frame or data.table |
cols |
List of numeric column(s) name(s) of data_set to transform. To transform all characters, set it to "auto". (character, default to "auto") |
n_bins |
Number of group to compute (numeric, default to 10) |
type |
Type of discretization ("equal_width" or "equal_freq") |
verbose |
Should the algorithm talk? (Logical, default to TRUE) |
Details
Using equal freq first bin will start at -Inf and last bin will end at +Inf.
Value
A list where each element name is a column name of data set and each element contains bins to discretize this column.
Examples
# Load data
data(tiny_messy_adult)
head(tiny_messy_adult)
# Compute bins
bins <- build_bins(tiny_messy_adult, cols = "auto", n_bins = 5, type = "equal_freq")
print(bins)
[Package dataPreparation version 1.1.1 Index]