Nothing
testthat::test_that(desc = "returns expexted value for normal parameters - small example",
code = {
conf_train <- 0.6
conf_eval <- 0.5
testthat::expect_type(object = consistency(conf_train = conf_train, conf_eval = conf_eval),
type = "double")
testthat::expect_vector(object= consistency(conf_train = conf_train, conf_eval = conf_eval),
ptype = numeric(length = 0))
testthat::expect_length(object = consistency(conf_train = conf_train, conf_eval = conf_eval),
n = 1)
testthat::expect_equal(object = consistency(conf_train = conf_train, conf_eval = conf_eval),
expected = -0.1)
testthat::expect_equal(object = consistency(conf_train = 0.93, conf_eval = 0.21), expected = -0.72)
testthat::expect_equal(object = consistency(conf_train = 0.43, conf_eval = 0.35), expected = -0.08)
testthat::expect_equal(object = consistency(conf_train = 0.87, conf_eval = 0.71), expected = -0.16)
testthat::expect_equal(object = consistency(conf_train = 0.67, conf_eval = 0.78), expected = 0.11)
testthat::expect_equal(object = consistency(conf_train = 0.67, conf_eval = NA_real_), expected = NA_real_) %>% suppressWarnings()
testthat::expect_equal(object = consistency(conf_train = NA_real_, conf_eval = 0.78), expected = NA_real_) %>% suppressWarnings()
testthat::expect_equal(object = consistency(conf_train = NA_real_, conf_eval = NA_real_), expected = NA_real_) %>% suppressWarnings()
}
)
testthat::test_that(desc = "returns expexted value for normal parameters - long example",
code = {
withr::local_seed(seed = 12345,
.rng_kind = "Mersenne-Twister",
.rng_normal_kind = "Inversion",
.rng_sample_kind = "Rejection")
observations <- c(rep(x = FALSE, times = 500),
rep(x = TRUE, times = 500))
predictions <- c(runif(n = 500, min = 0, max = 0.7),
runif(n = 500, min = 0.3, max = 1))
dataset <- data.frame(
observations = observations,
predictions = predictions,
evaluation_mask = c(rep(x = FALSE, times = 250),
rep(x = TRUE, times = 250),
rep(x = FALSE, times = 250),
rep(x = TRUE, times = 250))
)
thresholds_whole <- thresholds(observations = dataset$observations,
predictions = dataset$predictions)
confidence_training <- confidence(observations = dataset$observations[!dataset$evaluation_mask],
predictions = dataset$predictions[!dataset$evaluation_mask],
thresholds = thresholds_whole) # 0.602
confidence_evaluation <- confidence(observations = dataset$observations[dataset$evaluation_mask],
predictions = dataset$predictions[dataset$evaluation_mask],
thresholds = thresholds_whole) # 0.520
testthat::expect_equal(object = round(x = consistency(conf_train = confidence_training, conf_eval = confidence_evaluation), digits = 8), expected = -0.08302792)
}
)
testthat::test_that(desc = "returns errors/warnings if needed - parameter: conf_train",
code = {
testthat::expect_error(object = consistency(conf_eval = 0.6),
regexp = NULL)
testthat::expect_warning(object = consistency(conf_train = 1.3, conf_eval = 0.6),
regexp = NULL)
testthat::expect_warning(object = consistency(conf_train = -0.2, conf_eval = 0.6),
regexp = NULL)
testthat::expect_warning(object = consistency(conf_train = NA_real_, conf_eval = 0.6),
regexp = NULL)
testthat::expect_silent(object = consistency(conf_train = 0.8, conf_eval = 0.6))
testthat::expect_error(object = consistency(conf_train = "0.8", conf_eval = 0.6),
regexp = NULL)
testthat::expect_error(object = consistency(conf_train = numeric(length = 0), conf_eval = 0.6),
regexp = NULL)
testthat::expect_warning(object = consistency(conf_train = c(0.7, 0.8), conf_eval = 0.6),
regexp = NULL)
}
)
testthat::test_that(desc = "returns errors/warnings if needed - parameter: conf_eval",
code = {
testthat::expect_error(object = consistency(conf_train = 0.8),
regexp = NULL)
testthat::expect_warning(object = consistency(conf_train = 0.8, conf_eval = 1.1),
regexp = NULL)
testthat::expect_warning(object = consistency(conf_train = 0.8, conf_eval = -0.7),
regexp = NULL)
testthat::expect_warning(object = consistency(conf_train = 0.8, conf_eval = NA_real_),
regexp = NULL)
testthat::expect_silent(object = consistency(conf_train = 0.8, conf_eval = 0.6))
testthat::expect_error(object = consistency(conf_train = 0.8, conf_eval = "0.6"),
regexp = NULL)
testthat::expect_error(object = consistency(conf_train = 0.8, conf_eval = numeric(length = 0)),
regexp = NULL)
testthat::expect_warning(object = consistency(conf_train = 0.8, conf_eval = c(0.7, 0.6)),
regexp = NULL)
}
)
testthat::test_that(desc = "returns errors/warnings if needed - both parameters",
code = {
testthat::expect_error(object = consistency(),
regexp = NULL)
}
)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.