loo_encode3: Do Owen Zhang style leave-one-out encoding of a categorical....

Usage Arguments Details Value Examples

Usage

1
loo_encode3(id, resp)

Arguments

id

vector of identifiers to group over

resp

vector of response to summarise

Details

Take the mean of a variable for all rows with the same id except for the current row, so as to avoid leakage.

Value

vector of one-left-out summarised response over id

Examples

1
2
3
4
5
6
test_data <- data.frame(
  id = c(rep("a", 5), rep("b", 3), rep("c", 2), "d"),
  resp = c(1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1)
)

loo_encode(test_data$id, test_data$resp)

germayneng/DogEncode documentation built on Sept. 2, 2019, 11:02 a.m.