test_that("awe_registry lists candidates without fitting", { reg_c <- awe_registry("continuous") reg_b <- awe_registry("binary") expect_true(all(c("model", "has_probabilities") %in% names(reg_c))) expect_true("linear_regression" %in% reg_c$model) expect_true("logistic_or_multinomial" %in% reg_b$model) }) test_that("expanded model bank includes new regression candidates", { m <- awe_model(mtcars, target = "mpg", k = 3, seed = 1) expect_true("knn_regression" %in% m$leaderboard$model) }) test_that("expanded model bank includes new classification candidates", { m <- awe_model(iris, target = "Species", k = 3, seed = 1) expect_true(any(c("lda", "qda") %in% m$leaderboard$model)) }) test_that("awe_ensemble builds a working weighted ensemble", { m <- awe_model(mtcars, target = "mpg", k = 3, seed = 1) ens <- awe_ensemble(m, top_n = 3) expect_s3_class(ens, "AWEEnsemble") expect_s3_class(ens, "AWEWrapper") p <- predict(ens, newdata = mtcars) expect_length(p, nrow(mtcars)) expect_true(all(is.finite(p))) }) test_that("awe_ensemble errors with too few valid candidates", { m <- awe_model(mtcars, target = "mpg", k = 3, models = "linear_regression", seed = 1) expect_error(awe_ensemble(m, top_n = 3)) }) test_that("awe_compare stacks leaderboards across runs", { m1 <- awe_model(mtcars, target = "mpg", k = 3, seed = 1) m2 <- awe_model(mtcars, target = "mpg", k = 3, models = c("linear_regression", "decision_tree"), seed = 1) cmp <- awe_compare(full = m1, restricted = m2) expect_s3_class(cmp, "AWECompare") expect_setequal(unique(cmp$leaderboard$run), c("full", "restricted")) }) test_that("awe_tune finds a best hyperparameter combination", { tn <- awe_tune(mtcars, target = "mpg", model = "decision_tree", k = 3, seed = 1) expect_s3_class(tn, "AWETune") expect_true("cp" %in% names(tn$best_params)) expect_s3_class(tn$wrapper, "AWEWrapper") p <- predict(tn$wrapper, newdata = mtcars) expect_length(p, nrow(mtcars)) }) test_that("awe_save/awe_load round-trip an AWEModel", { m <- awe_model(mtcars, target = "mpg", k = 3, seed = 1) f <- tempfile(fileext = ".rds") awe_save(m, f) m2 <- awe_load(f) expect_equal(m$best_name, m2$best_name) }) test_that("plot_roc computes an AUC in [0, 1] for a binary target", { d <- iris[iris$Species != "setosa", ] d$Species <- droplevels(d$Species) m <- awe_model(d, target = "Species", k = 3, seed = 1) w <- awe_wrap(m) res <- plot_roc(w) expect_true(res$auc >= 0 && res$auc <= 1) expect_true(all(c("fpr", "tpr") %in% names(res$roc))) }) test_that("plot_confusion runs without error on a classification evaluation", { m <- awe_model(iris, target = "Species", k = 3, seed = 1) w <- awe_wrap(m) ev <- awe_evaluate(w, newdata = iris) expect_error(plot_confusion(ev), NA) }) test_that("plot_confusion errors on a regression evaluation", { m <- awe_model(mtcars, target = "mpg", k = 3, seed = 1) w <- awe_wrap(m) ev <- awe_evaluate(w, newdata = mtcars) expect_error(plot_confusion(ev)) }) test_that("plot_residuals runs without error on a regression wrapper", { m <- awe_model(mtcars, target = "mpg", k = 3, seed = 1) w <- awe_wrap(m) expect_error(plot_residuals(w), NA) }) test_that("eda_report runs without error", { expect_error(eda_report(mtcars, vars = c("mpg", "hp", "wt")), NA) }) test_that("theme_awe and awe_palette are usable", { expect_true(inherits(theme_awe(), "theme")) expect_length(awe_palette(4), 4) expect_length(awe_palette(20), 20) }) test_that("plot.awe supports roc/confusion/residuals types", { fit_c <- awe(mtcars, target = "mpg", k = 3, seed = 1) expect_error(plot(fit_c, type = "residuals"), NA) d <- iris[iris$Species != "setosa", ] d$Species <- droplevels(d$Species) fit_b <- awe(d, target = "Species", k = 3, seed = 1) expect_error(plot(fit_b, type = "roc"), NA) expect_error(plot(fit_b, type = "confusion"), NA) })