tests/testthat/test-auc.R

testthat::test_that("`performance_score_auc()` works", {

  data(vi)

    #perfect prediction
    x <- performance_score_auc(
      o = vi$vi_binomial,
      p = vi$vi_numeric
      )

    testthat::expect_true(
      x == 1
    )

    #random prediction
    x <- performance_score_auc(
      o = vi$vi_binomial,
      p = runif(n = nrow(vi))
    )

    testthat::expect_true(
      x < 1
    )

    #error
    testthat::expect_error(
      x <- performance_score_auc(
        o = runif(n = nrow(vi)),
        p = vi$vi_binomial
      )
    )

    testthat::expect_error(
      x <- performance_score_auc(
        o = NULL,
        p = vi$vi_binomial
      )
    )

    testthat::expect_error(
      x <- performance_score_auc(
        o = vi$vi_binomial,
        p = NULL
      )
    )

})

Try the collinear package in your browser

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

collinear documentation built on April 12, 2025, 1:36 a.m.