diff --git a/DESCRIPTION b/DESCRIPTION index 9fe2a410f..89f6e2b5a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -80,4 +80,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 diff --git a/NEWS.md b/NEWS.md index be6c445f2..e900874cb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # parsnip (development version) +* `surv_reg()` is now defunct and will error if called. Please use `survival_reg()` instead (#1206). + # parsnip 1.3.3 * Bug fix in how tunable parameters were configured for brulee neural networks. diff --git a/R/surv_reg.R b/R/surv_reg.R index a515e42d1..a24417766 100644 --- a/R/surv_reg.R +++ b/R/surv_reg.R @@ -27,32 +27,37 @@ #' @keywords internal #' @export surv_reg <- function(mode = "regression", engine = "survival", dist = NULL) { + lifecycle::deprecate_stop("1.4.0", "surv_reg()", "survival_reg()") - lifecycle::deprecate_warn("0.1.6", "surv_reg()", "survival_reg()") - - args <- list( - dist = enquo(dist) - ) - - new_model_spec( - "surv_reg", - args = args, - eng_args = NULL, - mode = mode, - user_specified_mode = !missing(mode), - method = NULL, - engine = engine, - user_specified_engine = !missing(engine) - ) - } + args <- list( + dist = enquo(dist) + ) + new_model_spec( + "surv_reg", + args = args, + eng_args = NULL, + mode = mode, + user_specified_mode = !missing(mode), + method = NULL, + engine = engine, + user_specified_engine = !missing(engine) + ) +} + +# nocov # ------------------------------------------------------------------------------ #' @method update surv_reg #' @rdname parsnip_update #' @export -update.surv_reg <- function(object, parameters = NULL, dist = NULL, fresh = FALSE, ...) { - +update.surv_reg <- function( + object, + parameters = NULL, + dist = NULL, + fresh = FALSE, + ... +) { args <- list( dist = enquo(dist) ) @@ -84,14 +89,13 @@ translate.surv_reg <- function(x, engine = x$engine, ...) { #' @export check_args.surv_reg <- function(object, call = rlang::caller_env()) { - if (object$engine == "flexsurv") { - args <- lapply(object$args, rlang::eval_tidy) # `dist` has no default in the function - if (all(names(args) != "dist") || is.null(args$dist)) + if (all(names(args) != "dist") || is.null(args$dist)) { object$args$dist <- "weibull" + } } invisible(object) @@ -132,6 +136,11 @@ flexsurv_mean <- function(results, object) { flexsurv_quant <- function(results, object) { results <- map(results, as_tibble) names(results) <- NULL - results <- map(results, setNames, c(".quantile", ".pred", ".pred_lower", ".pred_upper")) + results <- map( + results, + setNames, + c(".quantile", ".pred", ".pred_lower", ".pred_upper") + ) } +# nocov end diff --git a/R/surv_reg_data.R b/R/surv_reg_data.R index a37dc50bd..af01f2a8a 100644 --- a/R/surv_reg_data.R +++ b/R/surv_reg_data.R @@ -1,3 +1,4 @@ +# nocov set_new_model("surv_reg") set_model_mode("surv_reg", "regression") @@ -50,12 +51,11 @@ set_pred( pre = NULL, post = flexsurv_mean, func = c(fun = "summary"), - args = - list( - object = expr(object$fit), - newdata = expr(new_data), - type = "mean" - ) + args = list( + object = expr(object$fit), + newdata = expr(new_data), + type = "mean" + ) ) ) @@ -106,11 +106,12 @@ set_pred( pre = NULL, post = NULL, func = c(fun = "predict"), - args = - list( - object = expr(object$fit), - newdata = expr(new_data), - type = "response" - ) + args = list( + object = expr(object$fit), + newdata = expr(new_data), + type = "response" + ) ) ) + +# nocov end diff --git a/man/C5_rules.Rd b/man/C5_rules.Rd index 83f60ee69..cd5ce5da8 100644 --- a/man/C5_rules.Rd +++ b/man/C5_rules.Rd @@ -55,7 +55,7 @@ C5_rules(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("C5_rules") C5_rules() diff --git a/man/add_rowindex.Rd b/man/add_rowindex.Rd index ae2d9e7f4..fa4a5e678 100644 --- a/man/add_rowindex.Rd +++ b/man/add_rowindex.Rd @@ -16,7 +16,7 @@ The same data frame with a column of 1-based integers named \code{.row}. Add a column of row numbers to a data frame } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} mtcars |> add_rowindex() \dontshow{\}) # examplesIf} } diff --git a/man/augment.Rd b/man/augment.Rd index 90d777159..fca1241c5 100644 --- a/man/augment.Rd +++ b/man/augment.Rd @@ -49,7 +49,7 @@ metrics in the \pkg{yardstick} package. } } \examples{ -\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("modeldata")) withAutoprint(\{ # examplesIf} car_trn <- mtcars[11:32,] car_tst <- mtcars[ 1:10,] diff --git a/man/bart.Rd b/man/bart.Rd index da6cc7335..f7c84a6c3 100644 --- a/man/bart.Rd +++ b/man/bart.Rd @@ -75,7 +75,7 @@ bart(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("bart") bart(mode = "regression", trees = 5) diff --git a/man/boost_tree.Rd b/man/boost_tree.Rd index a36a4de25..97f4f49f1 100644 --- a/man/boost_tree.Rd +++ b/man/boost_tree.Rd @@ -81,7 +81,7 @@ boost_tree(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("boost_tree") boost_tree(mode = "classification", trees = 20) diff --git a/man/condense_control.Rd b/man/condense_control.Rd index d347bcd3e..e006893ca 100644 --- a/man/condense_control.Rd +++ b/man/condense_control.Rd @@ -27,7 +27,7 @@ throughout the tidymodels packages. It is now assumed that each control function is either a subset or a superset of another control function. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} ctrl <- control_parsnip(catch = TRUE) ctrl$allow_par <- TRUE str(ctrl) diff --git a/man/control_parsnip.Rd b/man/control_parsnip.Rd index a281331c8..b82f6e975 100644 --- a/man/control_parsnip.Rd +++ b/man/control_parsnip.Rd @@ -27,7 +27,7 @@ Pass options to the \code{\link[=fit.model_spec]{fit.model_spec()}} function to output and computations } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} control_parsnip(verbosity = 2L) \dontshow{\}) # examplesIf} } diff --git a/man/ctree_train.Rd b/man/ctree_train.Rd index dc0cf484b..5bc3c858b 100644 --- a/man/ctree_train.Rd +++ b/man/ctree_train.Rd @@ -74,7 +74,7 @@ These functions are slightly different APIs for \code{\link[partykit:ctree]{part arguments (as opposed to being specified in \code{\link[partykit:ctree_control]{partykit::ctree_control()}}). } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} if (rlang::is_installed(c("modeldata", "partykit"))) { data(bivariate, package = "modeldata") ctree_train(Class ~ ., data = bivariate_train) diff --git a/man/decision_tree.Rd b/man/decision_tree.Rd index fbdb31742..456a7d366 100644 --- a/man/decision_tree.Rd +++ b/man/decision_tree.Rd @@ -56,7 +56,7 @@ decision_tree(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("decision_tree") decision_tree(mode = "classification", tree_depth = 5) diff --git a/man/doc-tools.Rd b/man/doc-tools.Rd index 7257c6a3b..8f6ee6364 100644 --- a/man/doc-tools.Rd +++ b/man/doc-tools.Rd @@ -50,7 +50,7 @@ the References section). Most parsnip users will not need to use these functions or documentation. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # See this file for step-by-step instructions. system.file("README-DOCS.md", package = "parsnip") diff --git a/man/dot-get_prediction_column_names.Rd b/man/dot-get_prediction_column_names.Rd index e316107ca..7add7c851 100644 --- a/man/dot-get_prediction_column_names.Rd +++ b/man/dot-get_prediction_column_names.Rd @@ -19,7 +19,7 @@ A list with elements \code{"estimate"} and \code{"probabilities"}. columns for the primary prediction types for a model. } \examples{ -\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("modeldata")) withAutoprint(\{ # examplesIf} library(dplyr) library(modeldata) data("two_class_dat") diff --git a/man/dot-model_param_name_key.Rd b/man/dot-model_param_name_key.Rd index ea391d5b3..d91632bf9 100644 --- a/man/dot-model_param_name_key.Rd +++ b/man/dot-model_param_name_key.Rd @@ -22,7 +22,7 @@ tuning parameter names, the standardized parsnip parameter names, and the argument names to the underlying fit function for the engine. } \examples{ -\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("dials")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("dials")) withAutoprint(\{ # examplesIf} mod <- linear_reg(penalty = tune("regularization"), mixture = tune()) |> set_engine("glmnet") diff --git a/man/extract-parsnip.Rd b/man/extract-parsnip.Rd index 95355f55d..19155db57 100644 --- a/man/extract-parsnip.Rd +++ b/man/extract-parsnip.Rd @@ -70,7 +70,7 @@ or silently generating incorrect predictions. }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("dials")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("dials")) withAutoprint(\{ # examplesIf} lm_spec <- linear_reg() |> set_engine("lm") lm_fit <- fit(lm_spec, mpg ~ ., data = mtcars) diff --git a/man/fit.Rd b/man/fit.Rd index 295312238..67bf23b54 100644 --- a/man/fit.Rd +++ b/man/fit.Rd @@ -110,7 +110,7 @@ Sparse data is supported, with the use of the \code{x} argument in \code{fit_xy( compatibility. } \examples{ -\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("modeldata")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("modeldata")) withAutoprint(\{ # examplesIf} # Although `glm()` only has a formula interface, different # methods for specifying the model can be used diff --git a/man/fit_control.Rd b/man/fit_control.Rd index aba2781d9..1b3f89fe7 100644 --- a/man/fit_control.Rd +++ b/man/fit_control.Rd @@ -32,7 +32,7 @@ output and computations \code{fit_control()} is deprecated in favor of \code{control_parsnip()}. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} fit_control(verbosity = 2L) \dontshow{\}) # examplesIf} } diff --git a/man/gen_additive_mod.Rd b/man/gen_additive_mod.Rd index 8829dcb3f..b038c7ced 100644 --- a/man/gen_additive_mod.Rd +++ b/man/gen_additive_mod.Rd @@ -54,7 +54,7 @@ gen_additive_mod(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("gen_additive_mod") gen_additive_mod() diff --git a/man/get_model_env.Rd b/man/get_model_env.Rd index 3b20d554d..d9b8c6458 100644 --- a/man/get_model_env.Rd +++ b/man/get_model_env.Rd @@ -29,7 +29,7 @@ These functions read and write to the environment where the package stores information about model specifications. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # Access the model data: current_code <- get_model_env() ls(envir = current_code) diff --git a/man/glm_grouped.Rd b/man/glm_grouped.Rd index e8697c209..3557cbfbc 100644 --- a/man/glm_grouped.Rd +++ b/man/glm_grouped.Rd @@ -36,7 +36,7 @@ each factor level so that the outcome can be given to the formula as "number of events" format for binomial data. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} #---------------------------------------------------------------------------- # The same data set formatted three ways diff --git a/man/has_multi_predict.Rd b/man/has_multi_predict.Rd index 37279991a..5525f296e 100644 --- a/man/has_multi_predict.Rd +++ b/man/has_multi_predict.Rd @@ -44,7 +44,7 @@ returns the names of the arguments to \code{multi_predict()} for this model (if any). } \examples{ -\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("kknn")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("kknn")) withAutoprint(\{ # examplesIf} lm_model_idea <- linear_reg() |> set_engine("lm") has_multi_predict(lm_model_idea) lm_model_fit <- fit(lm_model_idea, mpg ~ ., data = mtcars) diff --git a/man/linear_reg.Rd b/man/linear_reg.Rd index e34f45652..a29cb157c 100644 --- a/man/linear_reg.Rd +++ b/man/linear_reg.Rd @@ -54,7 +54,7 @@ linear_reg(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("linear_reg") linear_reg() diff --git a/man/logistic_reg.Rd b/man/logistic_reg.Rd index b0e464906..e98ef99bc 100644 --- a/man/logistic_reg.Rd +++ b/man/logistic_reg.Rd @@ -67,7 +67,7 @@ This model fits a classification model for binary outcomes; for multiclass outcomes, see \code{\link[=multinom_reg]{multinom_reg()}}. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("logistic_reg") logistic_reg() diff --git a/man/mars.Rd b/man/mars.Rd index 2b893b066..748378f72 100644 --- a/man/mars.Rd +++ b/man/mars.Rd @@ -56,7 +56,7 @@ mars(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("mars") mars(mode = "regression", num_terms = 5) diff --git a/man/max_mtry_formula.Rd b/man/max_mtry_formula.Rd index 6dbe33e76..b89dd7c7a 100644 --- a/man/max_mtry_formula.Rd +++ b/man/max_mtry_formula.Rd @@ -24,7 +24,7 @@ This function potentially caps the value of \code{mtry} based on a formula and data set. This is a safe approach for survival and/or multivariate models. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # should be 9 max_mtry_formula(200, cbind(wt, mpg) ~ ., data = mtcars) \dontshow{\}) # examplesIf} diff --git a/man/min_cols.Rd b/man/min_cols.Rd index edb5d9d8a..14ca91b4e 100644 --- a/man/min_cols.Rd +++ b/man/min_cols.Rd @@ -31,7 +31,7 @@ fit. These functions check the possible range of the data and adjust them if needed (with a warning). } \examples{ -\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("kknn") & rlang::is_installed("ranger")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check() & rlang::is_installed("kknn") & rlang::is_installed("ranger")) withAutoprint(\{ # examplesIf} nearest_neighbor(neighbors= 100) |> set_engine("kknn") |> set_mode("regression") |> diff --git a/man/mlp.Rd b/man/mlp.Rd index 842de7ab0..12e3a848c 100644 --- a/man/mlp.Rd +++ b/man/mlp.Rd @@ -71,7 +71,7 @@ mlp(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("mlp") mlp(mode = "classification", penalty = 0.01) diff --git a/man/model_db.Rd b/man/model_db.Rd index ec674b9ea..e658f8adf 100644 --- a/man/model_db.Rd +++ b/man/model_db.Rd @@ -12,7 +12,7 @@ This is used in the RStudio add-in and captures information about mode specifications in various R packages. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} data(model_db) \dontshow{\}) # examplesIf} } diff --git a/man/model_fit.Rd b/man/model_fit.Rd index 5265cb7cd..350540ee2 100644 --- a/man/model_fit.Rd +++ b/man/model_fit.Rd @@ -40,7 +40,7 @@ This class and structure is the basis for how \pkg{parsnip} stores model objects after seeing the data and applying a model. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # Keep the `x` matrix if the data are not too big. spec_obj <- diff --git a/man/multinom_reg.Rd b/man/multinom_reg.Rd index 7f6314f26..eabf5ce52 100644 --- a/man/multinom_reg.Rd +++ b/man/multinom_reg.Rd @@ -66,7 +66,7 @@ This model fits a classification model for multiclass outcomes; for binary outcomes, see \code{\link[=logistic_reg]{logistic_reg()}}. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("multinom_reg") multinom_reg() diff --git a/man/nearest_neighbor.Rd b/man/nearest_neighbor.Rd index 9aadaa6b9..f7ce1bc47 100644 --- a/man/nearest_neighbor.Rd +++ b/man/nearest_neighbor.Rd @@ -60,7 +60,7 @@ nearest_neighbor(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("nearest_neighbor") nearest_neighbor(neighbors = 11) diff --git a/man/null_model.Rd b/man/null_model.Rd index aa16a4230..9a4093d98 100644 --- a/man/null_model.Rd +++ b/man/null_model.Rd @@ -54,7 +54,7 @@ call. For this type of model, the template of the fit calls are below: } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} null_model(mode = "regression") \dontshow{\}) # examplesIf} } diff --git a/man/nullmodel.Rd b/man/nullmodel.Rd index 7585422de..21d8e4c38 100644 --- a/man/nullmodel.Rd +++ b/man/nullmodel.Rd @@ -57,7 +57,7 @@ probabilities are requested, the percentage of the training set samples with the most prevalent class is returned. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} outcome <- factor(sample(letters[1:2], size = 100, diff --git a/man/parsnip-package.Rd b/man/parsnip-package.Rd index 2e074dc3b..86ce93064 100644 --- a/man/parsnip-package.Rd +++ b/man/parsnip-package.Rd @@ -30,7 +30,7 @@ Authors: Other contributors: \itemize{ \item Emil Hvitfeldt \email{emil.hvitfeldt@posit.co} [contributor] - \item Posit Software, PBC (03wc8by49) [copyright holder, funder] + \item Posit Software, PBC (\href{https://ror.org/03wc8by49}{ROR}) [copyright holder, funder] } } diff --git a/man/parsnip_update.Rd b/man/parsnip_update.Rd index d6e652c82..0a7782b62 100644 --- a/man/parsnip_update.Rd +++ b/man/parsnip_update.Rd @@ -471,7 +471,7 @@ If parameters of a model specification need to be modified, \code{update()} can be used in lieu of recreating the object from scratch. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # ------------------------------------------------------------------------------ @@ -480,7 +480,7 @@ model update(model, trees = 1) update(model, trees = 1, fresh = TRUE) \dontshow{\}) # examplesIf} -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # ------------------------------------------------------------------------------ @@ -489,13 +489,13 @@ model update(model, committees = 1) update(model, committees = 1, fresh = TRUE) \dontshow{\}) # examplesIf} -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} model <- pls(predictor_prop = 0.1) model update(model, predictor_prop = 1) update(model, predictor_prop = 1, fresh = TRUE) \dontshow{\}) # examplesIf} -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # ------------------------------------------------------------------------------ model <- rule_fit(trees = 10, min_n = 2) @@ -503,7 +503,7 @@ model update(model, trees = 1) update(model, trees = 1, fresh = TRUE) \dontshow{\}) # examplesIf} -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} model <- boost_tree(mtry = 10, min_n = 3) model update(model, mtry = 1) diff --git a/man/predict.model_fit.Rd b/man/predict.model_fit.Rd index 15bce19f8..f30fe9e56 100644 --- a/man/predict.model_fit.Rd +++ b/man/predict.model_fit.Rd @@ -138,7 +138,7 @@ produces. Set \code{increasing = FALSE} to suppress this behavior. } } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} library(dplyr) lm_model <- diff --git a/man/proportional_hazards.Rd b/man/proportional_hazards.Rd index de1b966ee..4283d7c46 100644 --- a/man/proportional_hazards.Rd +++ b/man/proportional_hazards.Rd @@ -65,7 +65,7 @@ survival model be specified via the formula interface. Proportional hazards models include the Cox model. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("proportional_hazards") proportional_hazards(mode = "censored regression") diff --git a/man/rand_forest.Rd b/man/rand_forest.Rd index 1ec974b0e..5ac829482 100644 --- a/man/rand_forest.Rd +++ b/man/rand_forest.Rd @@ -58,7 +58,7 @@ rand_forest(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("rand_forest") rand_forest(mode = "classification", trees = 2000) diff --git a/man/repair_call.Rd b/man/repair_call.Rd index 5c153b4f1..9b3e40ed1 100644 --- a/man/repair_call.Rd +++ b/man/repair_call.Rd @@ -28,7 +28,7 @@ other functions. For example, some arguments may still be quosures and the functions and methods. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} fitted_model <- linear_reg() |> diff --git a/man/required_pkgs.model_spec.Rd b/man/required_pkgs.model_spec.Rd index 4460576d5..d29fee4e1 100644 --- a/man/required_pkgs.model_spec.Rd +++ b/man/required_pkgs.model_spec.Rd @@ -23,7 +23,7 @@ A character vector Determine required packages for a model } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} should_fail <- try(required_pkgs(linear_reg(engine = NULL)), silent = TRUE) should_fail diff --git a/man/rule_fit.Rd b/man/rule_fit.Rd index 5fc65b082..7cce87dbf 100644 --- a/man/rule_fit.Rd +++ b/man/rule_fit.Rd @@ -89,7 +89,7 @@ rule_fit(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("rule_fit") rule_fit() diff --git a/man/set_args.Rd b/man/set_args.Rd index 5a9bca054..692c48638 100644 --- a/man/set_args.Rd +++ b/man/set_args.Rd @@ -36,7 +36,7 @@ An updated model object. \code{set_args()} will replace existing values of the arguments. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} rand_forest() rand_forest() |> diff --git a/man/set_engine.Rd b/man/set_engine.Rd index 274703754..c1a838be2 100644 --- a/man/set_engine.Rd +++ b/man/set_engine.Rd @@ -54,7 +54,7 @@ argument to be passed directly to the engine fitting function, like } } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # First, set main arguments using the standardized names logistic_reg(penalty = 0.01, mixture = 1/3) |> # Now specify how you want to fit the model with another argument diff --git a/man/set_new_model.Rd b/man/set_new_model.Rd index bb08bb812..d2aa1c95f 100644 --- a/man/set_new_model.Rd +++ b/man/set_new_model.Rd @@ -145,7 +145,7 @@ accommodate a sparse matrix representation for predictors during fitting and tuning. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # set_new_model("shallow_learning_model") # Show the information about a model: diff --git a/man/show_engines.Rd b/man/show_engines.Rd index 31656ed73..14f5fc735 100644 --- a/man/show_engines.Rd +++ b/man/show_engines.Rd @@ -19,7 +19,7 @@ the \pkg{poissonreg} package adds additional engines for the \code{\link[=poisso model and these are not available unless \pkg{poissonreg} is loaded. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("linear_reg") \dontshow{\}) # examplesIf} } diff --git a/man/survival_reg.Rd b/man/survival_reg.Rd index 286b5f989..d1494e756 100644 --- a/man/survival_reg.Rd +++ b/man/survival_reg.Rd @@ -47,7 +47,7 @@ Since survival models typically involve censoring (and require the use of survival model be specified via the formula interface. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("survival_reg") survival_reg(mode = "censored regression", dist = "weibull") diff --git a/man/svm_linear.Rd b/man/svm_linear.Rd index 4a0ff97e4..4fab79222 100644 --- a/man/svm_linear.Rd +++ b/man/svm_linear.Rd @@ -50,7 +50,7 @@ svm_linear(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("svm_linear") svm_linear(mode = "classification") diff --git a/man/svm_poly.Rd b/man/svm_poly.Rd index 071dac91e..34fce7737 100644 --- a/man/svm_poly.Rd +++ b/man/svm_poly.Rd @@ -62,7 +62,7 @@ svm_poly(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("svm_poly") svm_poly(mode = "classification", degree = 1.2) diff --git a/man/svm_rbf.Rd b/man/svm_rbf.Rd index 3be0777b1..77ec54772 100644 --- a/man/svm_rbf.Rd +++ b/man/svm_rbf.Rd @@ -60,7 +60,7 @@ svm_rbf(argument = !!value) }\if{html}{\out{}} } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} show_engines("svm_rbf") svm_rbf(mode = "classification", rbf_sigma = 0.2) diff --git a/man/tidy.nullmodel.Rd b/man/tidy.nullmodel.Rd index 81d078004..482af6295 100644 --- a/man/tidy.nullmodel.Rd +++ b/man/tidy.nullmodel.Rd @@ -18,7 +18,7 @@ A tibble with column \code{value}. Return the results of \code{nullmodel} as a tibble } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} nullmodel(mtcars[,-1], mtcars$mpg) |> tidy() \dontshow{\}) # examplesIf} diff --git a/man/translate.Rd b/man/translate.Rd index b181fe49e..8c88e5505 100644 --- a/man/translate.Rd +++ b/man/translate.Rd @@ -42,7 +42,7 @@ to understand what the underlying syntax would be. It should not be used to modify the model specification. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} lm_spec <- linear_reg(penalty = 0.01) # `penalty` is tranlsated to `lambda` diff --git a/man/varying_args.Rd b/man/varying_args.Rd index c019d947f..f24852356 100644 --- a/man/varying_args.Rd +++ b/man/varying_args.Rd @@ -38,7 +38,7 @@ or a \code{recipe} is used. For a \code{model_spec}, the first class is used. Fo a \code{recipe}, the unique step \code{id} is used. } \examples{ -\dontshow{if (!parsnip:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (!parsnip:::is_cran_check()) withAutoprint(\{ # examplesIf} # List all possible varying args for the random forest spec rand_forest() |> varying_args() diff --git a/tests/testthat/test-surv_reg.R b/tests/testthat/test-surv_reg.R deleted file mode 100644 index 145029441..000000000 --- a/tests/testthat/test-surv_reg.R +++ /dev/null @@ -1,22 +0,0 @@ -test_that('updating', { - rlang::local_options(lifecycle_verbosity = "quiet") - - expect_snapshot( - surv_reg() |> - set_engine("flexsurv", cl = 0.99) |> - update(cl = tune()) - ) -}) - -test_that('bad input', { - rlang::local_options(lifecycle_verbosity = "quiet") - - expect_snapshot(error = TRUE, surv_reg(mode = ", classification")) - expect_snapshot(error = TRUE, translate(surv_reg() |> set_engine("wat"))) - expect_snapshot(res <- translate(surv_reg() |> set_engine(NULL)), error = TRUE) -}) - -test_that("deprecation warning", { - rlang::local_options(lifecycle_verbosity = "warning") - expect_snapshot(surv_reg()) -}) diff --git a/tests/testthat/test-surv_reg_flexsurv.R b/tests/testthat/test-surv_reg_flexsurv.R deleted file mode 100644 index 11da8531c..000000000 --- a/tests/testthat/test-surv_reg_flexsurv.R +++ /dev/null @@ -1,60 +0,0 @@ - - -# ------------------------------------------------------------------------------ - -test_that('flexsurv execution', { - skip_if_not_installed("flexsurv") - skip_if_not_installed("survival") - - rlang::local_options(lifecycle_verbosity = "quiet") - surv_basic <- surv_reg() |> set_engine("flexsurv") - - expect_no_condition( - res <- fit( - surv_basic, - survival::Surv(time, status) ~ age, - data = lung, - control = ctrl - ) - ) - expect_no_condition( - res <- fit( - surv_basic, - survival::Surv(time) ~ age, - data = lung, - control = ctrl - ) - ) - expect_false(has_multi_predict(res)) - expect_equal(multi_predict_args(res), NA_character_) - - expect_snapshot( - error = TRUE, - res <- fit_xy( - surv_basic, - x = lung[, "age", drop = FALSE], - y = lung$time, - control = ctrl - ) - ) -}) - -test_that('flexsurv prediction', { - skip_if_not_installed("flexsurv") - skip_if_not_installed("survival") - - - rlang::local_options(lifecycle_verbosity = "quiet") - surv_basic <- surv_reg() |> set_engine("flexsurv") - - res <- fit( - surv_basic, - survival::Surv(time, status) ~ age, - data = lung, - control = ctrl - ) - exp_pred <- summary(extract_fit_engine(res), head(lung), type = "mean") - exp_pred <- do.call("rbind", unclass(exp_pred)) - exp_pred <- tibble(.pred = exp_pred$est) - expect_equal(exp_pred, predict(res, head(lung))) -}) diff --git a/tests/testthat/test-surv_reg_survreg.R b/tests/testthat/test-surv_reg_survreg.R deleted file mode 100644 index 6463d309c..000000000 --- a/tests/testthat/test-surv_reg_survreg.R +++ /dev/null @@ -1,57 +0,0 @@ - - -# ------------------------------------------------------------------------------ - -test_that('survival execution', { - skip_if_not_installed("survival") - rlang::local_options(lifecycle_verbosity = "quiet") - surv_basic <- surv_reg() |> set_engine("survival") - surv_lnorm <- surv_reg(dist = "lognormal") |> set_engine("survival") - - expect_no_condition( - res <- fit( - surv_basic, - survival::Surv(time, status) ~ age + sex, - data = lung, - control = ctrl - ) - ) - - expect_no_condition( - res <- fit( - surv_lnorm, - survival::Surv(time) ~ age + sex, - data = lung, - control = ctrl - ) - ) - expect_snapshot( - error = TRUE, - res <- fit_xy( - surv_basic, - x = lung[, c("age", "sex")], - y = lung$time, - control = ctrl - ) - ) -}) - -test_that('survival prediction', { - skip_if_not_installed("survival") - - rlang::local_options(lifecycle_verbosity = "quiet") - surv_basic <- surv_reg() |> set_engine("survival") - surv_lnorm <- surv_reg(dist = "lognormal") |> set_engine("survival") - - res <- fit( - surv_basic, - survival::Surv(time, status) ~ age + sex, - data = lung, - control = ctrl - ) - exp_pred <- predict(extract_fit_engine(res), head(lung)) - exp_pred <- tibble(.pred = unname(exp_pred)) - expect_equal(exp_pred, predict(res, head(lung))) -}) - - diff --git a/tests/testthat/test-translate.R b/tests/testthat/test-translate.R index 19aafc3f1..a3a36fedb 100644 --- a/tests/testthat/test-translate.R +++ b/tests/testthat/test-translate.R @@ -29,9 +29,13 @@ test_that("arguments (boost_tree)", { expect_snapshot(translate_args(basic_class |> set_engine("xgboost"))) expect_snapshot(translate_args(basic_class |> set_engine("C5.0"))) - expect_snapshot(translate_args(basic_class |> set_engine("C5.0", rules = TRUE))) + expect_snapshot(translate_args( + basic_class |> set_engine("C5.0", rules = TRUE) + )) - expect_snapshot(translate_args(basic_reg |> set_engine("xgboost", print_every_n = 10L))) + expect_snapshot(translate_args( + basic_reg |> set_engine("xgboost", print_every_n = 10L) + )) expect_snapshot(translate_args(trees |> set_engine("C5.0"))) expect_snapshot(translate_args(trees |> set_engine("xgboost"))) @@ -44,14 +48,21 @@ test_that("arguments (boost_tree)", { test_that("arguments (decision_tree)", { basic_class <- decision_tree(mode = "classification") basic_reg <- decision_tree(mode = "regression") - cost_complexity <- decision_tree(cost_complexity = 15, mode = "classification") + cost_complexity <- decision_tree( + cost_complexity = 15, + mode = "classification" + ) split_num <- decision_tree(min_n = 15, mode = "classification") expect_snapshot(translate_args(basic_class |> set_engine("rpart"))) expect_snapshot(translate_args(basic_class |> set_engine("C5.0"))) - expect_snapshot(translate_args(basic_class |> set_engine("C5.0", rules = TRUE))) + expect_snapshot(translate_args( + basic_class |> set_engine("C5.0", rules = TRUE) + )) - expect_snapshot(translate_args(basic_reg |> set_engine("rpart", model = TRUE))) + expect_snapshot(translate_args( + basic_reg |> set_engine("rpart", model = TRUE) + )) expect_snapshot(translate_args(cost_complexity |> set_engine("rpart"))) @@ -65,7 +76,9 @@ test_that("arguments (default)", { basic <- null_model(mode = "regression") expect_snapshot(translate_args(basic |> set_engine("parsnip"))) - expect_snapshot(translate_args(basic |> set_engine("parsnip", keepxy = FALSE))) + expect_snapshot(translate_args( + basic |> set_engine("parsnip", keepxy = FALSE) + )) }) # translate.linear_reg --------------------------------------------------------- @@ -78,9 +91,13 @@ test_that("arguments (linear_reg)", { expect_snapshot(translate_args(basic |> set_engine("lm"))) expect_snapshot(translate_args(basic |> set_engine("lm", model = FALSE))) expect_snapshot(translate_args(basic |> set_engine("glm"))) - expect_snapshot(translate_args(basic |> set_engine("glm", family = "quasipoisson"))) + expect_snapshot(translate_args( + basic |> set_engine("glm", family = "quasipoisson") + )) expect_snapshot(translate_args(basic |> set_engine("stan"))) - expect_snapshot(translate_args(basic |> set_engine("stan", chains = 1, iter = 5))) + expect_snapshot(translate_args( + basic |> set_engine("stan", chains = 1, iter = 5) + )) expect_snapshot(translate_args(basic |> set_engine("spark"))) expect_snapshot(translate_args(basic |> set_engine("spark", max_iter = 20))) expect_snapshot(translate_args(basic |> set_engine("glmnet")), error = TRUE) @@ -91,7 +108,9 @@ test_that("arguments (linear_reg)", { expect_snapshot(translate_args(penalty |> set_engine("glmnet"))) expect_snapshot(translate_args(penalty |> set_engine("glmnet", nlambda = 10))) - expect_snapshot(translate_args(penalty |> set_engine("glmnet", path_values = 4:2))) + expect_snapshot(translate_args( + penalty |> set_engine("glmnet", path_values = 4:2) + )) expect_snapshot(translate_args(penalty |> set_engine("spark"))) }) @@ -111,7 +130,9 @@ test_that("arguments (logistic_reg)", { expect_snapshot(translate_args(basic |> set_engine("LiblineaR"))) expect_snapshot(translate_args(basic |> set_engine("LiblineaR", bias = 0))) expect_snapshot(translate_args(basic |> set_engine("stan"))) - expect_snapshot(translate_args(basic |> set_engine("stan", chains = 1, iter = 5))) + expect_snapshot(translate_args( + basic |> set_engine("stan", chains = 1, iter = 5) + )) expect_snapshot(translate_args(basic |> set_engine("spark"))) expect_snapshot(translate_args(basic |> set_engine("spark", max_iter = 20))) @@ -120,11 +141,16 @@ test_that("arguments (logistic_reg)", { expect_snapshot(translate_args(penalty |> set_engine("glmnet"))) expect_snapshot(translate_args(penalty |> set_engine("glmnet", nlambda = 10))) - expect_snapshot(translate_args(penalty |> set_engine("glmnet", path_values = 4:2))) + expect_snapshot(translate_args( + penalty |> set_engine("glmnet", path_values = 4:2) + )) expect_snapshot(translate_args(penalty |> set_engine("LiblineaR"))) expect_snapshot(translate_args(penalty |> set_engine("spark"))) - expect_snapshot(translate_args(mixture_v |> set_engine("glmnet")), error = TRUE) + expect_snapshot( + translate_args(mixture_v |> set_engine("glmnet")), + error = TRUE + ) expect_snapshot(translate_args(mixture_v |> set_engine("LiblineaR"))) expect_snapshot(translate_args(mixture_v |> set_engine("spark"))) }) @@ -152,16 +178,23 @@ test_that("arguments (mlp)", { all_args <- mlp( mode = "classification", - epochs = 2, hidden_units = 4, penalty = 0.0001, - dropout = 0, activation = "softmax" + epochs = 2, + hidden_units = 4, + penalty = 0.0001, + dropout = 0, + activation = "softmax" ) expect_snapshot(translate_args(hidden_units |> set_engine("nnet"))) expect_snapshot(translate_args(hidden_units |> set_engine("keras"))) expect_snapshot(translate_args(no_hidden_units |> set_engine("nnet"))) - expect_snapshot(translate_args(no_hidden_units |> set_engine("nnet", abstol = tune()))) - expect_snapshot(translate_args(no_hidden_units |> set_engine("keras", validation_split = 0.2))) + expect_snapshot(translate_args( + no_hidden_units |> set_engine("nnet", abstol = tune()) + )) + expect_snapshot(translate_args( + no_hidden_units |> set_engine("keras", validation_split = 0.2) + )) expect_snapshot(translate_args(hess |> set_engine("nnet", Hess = TRUE))) @@ -180,7 +213,9 @@ test_that("arguments (multinom_reg)", { expect_snapshot(translate_args(basic |> set_engine("glmnet")), error = TRUE) expect_snapshot(translate_args(mixture |> set_engine("glmnet"))) expect_snapshot(translate_args(penalty |> set_engine("glmnet"))) - expect_snapshot(translate_args(penalty |> set_engine("glmnet", path_values = 4:2))) + expect_snapshot(translate_args( + penalty |> set_engine("glmnet", path_values = 4:2) + )) expect_snapshot(translate_args(penalty |> set_engine("glmnet", nlambda = 10))) expect_snapshot(translate_args(mixture_v |> set_engine("glmnet"))) }) @@ -191,12 +226,17 @@ test_that("arguments (nearest_neighbor)", { basic <- nearest_neighbor(mode = "regression") neighbors <- nearest_neighbor(mode = "classification", neighbors = 2) - weight_func <- nearest_neighbor(mode = "classification", weight_func = "triangular") + weight_func <- nearest_neighbor( + mode = "classification", + weight_func = "triangular" + ) dist_power <- nearest_neighbor(mode = "classification", dist_power = 2) expect_snapshot(translate_args(basic |> set_engine("kknn"))) expect_snapshot(translate_args(neighbors |> set_engine("kknn"))) - expect_snapshot(translate_args(neighbors |> set_engine("kknn", scale = FALSE))) + expect_snapshot(translate_args( + neighbors |> set_engine("kknn", scale = FALSE) + )) expect_snapshot(translate_args(weight_func |> set_engine("kknn"))) expect_snapshot(translate_args(dist_power |> set_engine("kknn"))) }) @@ -212,9 +252,7 @@ test_that("arguments (proportional_hazards)", { # this is empty because the engines are not defined in parsnip expect_snapshot(basic |> translate_args()) # but we can check for the error if there is no penalty for glmnet - expect_snapshot(error = TRUE, - basic_incomplete |> translate_args() - ) + expect_snapshot(error = TRUE, basic_incomplete |> translate_args()) }) # translate.rand_forest -------------------------------------------------------- @@ -224,15 +262,21 @@ test_that("arguments (rand_forest)", { trees <- rand_forest(mode = "classification", trees = 1000) min_n <- rand_forest(mode = "regression", min_n = 5) - expect_snapshot(translate_args(basic |> set_engine("randomForest", norm.votes = FALSE))) - expect_snapshot(translate_args(basic |> set_engine("spark", min_info_gain = 2))) + expect_snapshot(translate_args( + basic |> set_engine("randomForest", norm.votes = FALSE) + )) + expect_snapshot(translate_args( + basic |> set_engine("spark", min_info_gain = 2) + )) expect_snapshot(translate_args(mtry |> set_engine("ranger"))) expect_snapshot(translate_args(mtry |> set_engine("randomForest"))) expect_snapshot(translate_args(mtry |> set_engine("spark"))) expect_snapshot(translate_args(trees |> set_engine("ranger"))) - expect_snapshot(translate_args(trees |> set_engine("ranger", importance = "impurity"))) + expect_snapshot(translate_args( + trees |> set_engine("ranger", importance = "impurity") + )) expect_snapshot(translate_args(trees |> set_engine("randomForest"))) expect_snapshot(translate_args(trees |> set_engine("spark"))) @@ -241,20 +285,6 @@ test_that("arguments (rand_forest)", { expect_snapshot(translate_args(min_n |> set_engine("spark"))) }) -# translate.surv_reg ----------------------------------------------------------- -test_that("arguments (surv_reg)", { - rlang::local_options(lifecycle_verbosity = "quiet") - - basic <- surv_reg() - normal <- surv_reg(dist = "lnorm") - dist_v <- surv_reg(dist = tune()) - - expect_snapshot(translate_args(basic |> set_engine("flexsurv"))) - expect_snapshot(translate_args(basic |> set_engine("flexsurv", cl = .99))) - expect_snapshot(translate_args(normal |> set_engine("flexsurv"))) - expect_snapshot(translate_args(dist_v |> set_engine("flexsurv"))) -}) - # translate.survival_reg ----------------------------------------------------------- test_that("arguments (survival_reg)", { suppressMessages({ @@ -263,7 +293,6 @@ test_that("arguments (survival_reg)", { # this is empty because the engines are not defined in parsnip expect_snapshot(basic |> translate_args()) - }) # translate.svm_linear --------------------------------------------------------- @@ -303,7 +332,11 @@ test_that("arguments (svm_rbf)", { test_that("translate tuning paramter names", { skip_if_not_installed("dials") - mod <- boost_tree(trees = tune("number of trees"), min_n = tune(), tree_depth = 3) + mod <- boost_tree( + trees = tune("number of trees"), + min_n = tune(), + tree_depth = 3 + ) expect_snapshot(.model_param_name_key(mod)) expect_snapshot(.model_param_name_key(mod, as_tibble = FALSE))