Description Usage Arguments Examples
Compute the empirical risk under cross-entropy loss for binary predictions.
1 | nll(prediction, outcome)
|
prediction |
A |
outcome |
A |
1 2 3 4 5 6 7 8 | n_obs <- 100
x <- rnorm(n_obs)
y <- rbinom(n_obs, 1, plogis(x^2))
test_x <- rnorm(n_obs)
test_y <- rbinom(n_obs, 1, plogis(test_x^2))
mod <- glm(y ~ x, family = "binomial")
pred <- predict(mod, newx = as.data.frame(test_x), type = "response")
error <- nll(prediction = unname(pred), outcome = test_y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.