tests/testthat/test_classif_logloss.R

test_that("logloss obs_loss works", {
  truth = factor(rep(c("a", "b"), each = 5), levels = c("a", "b"))
  prob = matrix(runif(length(truth) * 2), ncol = 2)
  prob = t(apply(prob, 1, function(x) x / sum(x)))
  colnames(prob) = levels(truth)
  expect_numeric(obs_logloss(truth, prob), len = length(truth))
})

Try the mlr3measures package in your browser

Any scripts or data that you put into this service are public.

mlr3measures documentation built on April 17, 2026, 5:06 p.m.