# NOT RUN {
# Build a data set
require(data.table)
dataSet <- data.table(student = c("Marie", "Marie", "Pierre", "Louis", "Louis"),
grades = c(1, 1, 2, 3, 4))
# Construct encoding
target_encoding <- build_target_encoding(dataSet, cols_to_encode = "student",
target_col = "grades", functions = c("mean", "sum"))
# Apply them
target_encode(dataSet, target_encoding = target_encoding)
# }
Run the code above in your browser using DataLab