diff --git a/DESCRIPTION b/DESCRIPTION index da3fb6d89..6e67909aa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: parsnip Title: A Common API to Modeling and Analysis Functions -Version: 1.1.1.9008 +Version: 1.2.0 Authors@R: c( person("Max", "Kuhn", , "max@posit.co", role = c("aut", "cre")), person("Davis", "Vaughan", , "davis@posit.co", role = "aut"), @@ -17,7 +17,7 @@ URL: https://github.com/tidymodels/parsnip, https://parsnip.tidymodels.org/ BugReports: https://github.com/tidymodels/parsnip/issues Depends: - R (>= 3.5) + R (>= 3.6) Imports: cli, dplyr (>= 1.1.0), @@ -76,4 +76,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.0 +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index b2bede299..869e2a030 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -76,6 +76,7 @@ S3method(predict_linear_pred,model_fit) S3method(predict_numeric,"_elnet") S3method(predict_numeric,"_glmnetfit") S3method(predict_numeric,model_fit) +S3method(predict_predint,model_fit) S3method(predict_quantile,model_fit) S3method(predict_raw,"_elnet") S3method(predict_raw,"_glmnetfit") @@ -283,12 +284,15 @@ export(pred_value_template) export(predict.model_fit) export(predict_class.model_fit) export(predict_classprob.model_fit) +export(predict_confint) export(predict_confint.model_fit) export(predict_hazard.model_fit) export(predict_linear_pred) export(predict_linear_pred.model_fit) export(predict_numeric) export(predict_numeric.model_fit) +export(predict_predint) +export(predict_predint.model_fit) export(predict_quantile.model_fit) export(predict_raw) export(predict_raw.model_fit) diff --git a/NEWS.md b/NEWS.md index 5627e18ed..002084d8d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,33 +1,38 @@ -# parsnip (development version) +# parsnip 1.2.0 -* We no longer add `eval_time` arguments to the prediction specification for the engine (#1039). - -* parsnip now lets the engines for [mlp()] check for acceptable values of the activation function (#1019) +## Bug Fixes * Tightened logic for outcome checking. This resolves issues—some errors and some silent failures—when atomic outcome variables have an attribute (#1060, #1061). -* `rpart_train()` has been deprecated in favor of using `decision_tree()` with the `"rpart"` engine or `rpart::rpart()` directly (#1044). - * Fixed bug in fitting some model types with the `"spark"` engine (#1045). * Fixed issues in metadata for the `"brulee"` engine where several arguments were mistakenly protected. (#1050, #1054) +* Fixed documentation for `mlp(engine = "brulee")`: the default values for `learn_rate` and `epochs` were swapped (#1018). + +* Fixed a bug in the integration with workflows where using a model formula with a formula preprocessor could result in a double intercept (#1033). + +## Other Changes + +* We no longer add `eval_time` arguments to the prediction specification for the engine (#1039). + +* parsnip now lets the engines for [mlp()] check for acceptable values of the activation function (#1019) + +* `rpart_train()` has been deprecated in favor of using `decision_tree()` with the `"rpart"` engine or `rpart::rpart()` directly (#1044). + * `.filter_eval_time()` was moved to the survival standalone file. * Improved errors and documentation related to special terms in formulas. See `?model_formula` to learn more. (#770, #1014) * Improved errors in cases where the outcome column is mis-specified. (#1003) -* Fixed documentation for `mlp(engine = "brulee")`: the default values for `learn_rate` and `epochs` were swapped (#1018). - * The `new_data` argument for the `predict()` method for `censoring_model_reverse_km` objects has been deprecated (#965). * When computing censoring weights, the resulting vectors are no longer named (#1023). -* Fixed a bug in the integration with workflows where using a model formula with a formula preprocessor could result in a double intercept (#1033). - * The `predict()` method for `censoring_model_reverse_km` objects now checks that `...` are empty (#1029). + # parsnip 1.1.1 * Fixed bug where prediction on rank deficient `lm()` models produced `.pred_res` instead of `.pred`. (#985) diff --git a/R/engine_docs.R b/R/engine_docs.R index 0ad656167..4806f2754 100644 --- a/R/engine_docs.R +++ b/R/engine_docs.R @@ -7,6 +7,10 @@ #' @keywords internal #' @export knit_engine_docs <- function(pattern = NULL) { + old_cli_opt <- options()$cli.unicode + on.exit(options(cli.unicode = old_cli_opt)) + options(cli.unicode = FALSE) + rmd_files <- list.files("man/rmd", pattern = "\\.Rmd", full.names = TRUE) if (!is.null(pattern)) { diff --git a/R/predict_interval.R b/R/predict_interval.R index 018228cdd..4595c1551 100644 --- a/R/predict_interval.R +++ b/R/predict_interval.R @@ -40,21 +40,29 @@ predict_confint.model_fit <- function(object, new_data, level = 0.95, std_error res } -# @export -# @keywords internal -# @rdname other_predict -# @inheritParams predict.model_fit +#' @export +#' @keywords internal +#' @rdname other_predict +#' @inheritParams predict.model_fit predict_confint <- function(object, ...) UseMethod("predict_confint") # ------------------------------------------------------------------------------ -# @keywords internal -# @rdname other_predict -# @inheritParams predict.model_fit -# @method predict_predint model_fit -# @export predict_predint.model_fit -# @export +#' @export +#' @keywords internal +#' @rdname other_predict +#' @inheritParams predict.model_fit +predict_predint <- function(object, ...) + UseMethod("predict_predint") + + +#' @keywords internal +#' @rdname other_predict +#' @inheritParams predict.model_fit +#' @method predict_predint model_fit +#' @export predict_predint.model_fit +#' @export predict_predint.model_fit <- function(object, new_data, level = 0.95, std_error = FALSE, ...) { check_spec_pred_type(object, "pred_int") @@ -88,10 +96,10 @@ predict_predint.model_fit <- function(object, new_data, level = 0.95, std_error res } -# @export -# @keywords internal -# @rdname other_predict -# @inheritParams predict.model_fit +#' @export +#' @keywords internal +#' @rdname other_predict +#' @inheritParams predict.model_fit predict_predint <- function(object, ...) UseMethod("predict_predint") diff --git a/R/surv_reg_flexsurv.R b/R/surv_reg_flexsurv.R deleted file mode 100644 index 39404798f..000000000 --- a/R/surv_reg_flexsurv.R +++ /dev/null @@ -1,9 +0,0 @@ -#' Parametric survival regression -#' -#' [flexsurv::flexsurvreg()] fits a parametric survival model. -#' -#' @includeRmd man/rmd/surv_reg_flexsurv.md details -#' -#' @name details_surv_reg_flexsurv -#' @keywords internal -NULL diff --git a/R/surv_reg_survival.R b/R/surv_reg_survival.R deleted file mode 100644 index e4b24a35d..000000000 --- a/R/surv_reg_survival.R +++ /dev/null @@ -1,9 +0,0 @@ -#' Parametric survival regression -#' -#' [survival::survreg()] fits a parametric survival model. -#' -#' @includeRmd man/rmd/surv_reg_survival.md details -#' -#' @name details_surv_reg_survival -#' @keywords internal -NULL diff --git a/man/details_gen_additive_mod_mgcv.Rd b/man/details_gen_additive_mod_mgcv.Rd index db9f55eab..b8bc31f32 100644 --- a/man/details_gen_additive_mod_mgcv.Rd +++ b/man/details_gen_additive_mod_mgcv.Rd @@ -94,8 +94,8 @@ using \code{s(x, df = 10)}) in the formula. Tuning can be accomplished using the \code{adjust_deg_free} parameter. When using a workflow, pass the \emph{model formula} to -\code{\link[=add_model]{add_model()}}’s \code{formula} argument, and a simplified -\emph{preprocessing formula} elsewhere. +\code{\link[workflows:add_model]{workflows::add_model()}}’s \code{formula} argument, +and a simplified \emph{preprocessing formula} elsewhere. \if{html}{\out{
}}\preformatted{spec <- gen_additive_mod() \%>\% diff --git a/man/details_mlp_brulee.Rd b/man/details_mlp_brulee.Rd index bac98abc6..fbe43eeff 100644 --- a/man/details_mlp_brulee.Rd +++ b/man/details_mlp_brulee.Rd @@ -10,11 +10,10 @@ For this engine, there are multiple modes: classification and regression \subsection{Tuning Parameters}{ -This model has 7 tuning parameters: +This model has 6 tuning parameters: \itemize{ \item \code{hidden_units}: # Hidden Units (type: integer, default: 3L) \item \code{penalty}: Amount of Regularization (type: double, default: 0.0) -\item \code{mixture}: Proportion of Lasso Penalty (type: double, default: 0.0) \item \code{epochs}: # Epochs (type: integer, default: 100L) \item \code{dropout}: Dropout Rate (type: double, default: 0.0) \item \code{learn_rate}: Learning Rate (type: double, default: 0.01) diff --git a/man/details_proportional_hazards_glmnet.Rd b/man/details_proportional_hazards_glmnet.Rd index c03ff3967..2f5dc5d14 100644 --- a/man/details_proportional_hazards_glmnet.Rd +++ b/man/details_proportional_hazards_glmnet.Rd @@ -102,7 +102,7 @@ predict(mod, pred_data, type = "survival", time = 500) \%>\% unnest(.pred) }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## # A tibble: 2 × 5 +\if{html}{\out{
}}\preformatted{## # A tibble: 2 x 5 ## .eval_time .pred_survival age ecog.ps rx ## ## 1 500 0.666 50 1 1 diff --git a/man/details_surv_reg_flexsurv.Rd b/man/details_surv_reg_flexsurv.Rd deleted file mode 100644 index 90877f735..000000000 --- a/man/details_surv_reg_flexsurv.Rd +++ /dev/null @@ -1,67 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/surv_reg_flexsurv.R -\name{details_surv_reg_flexsurv} -\alias{details_surv_reg_flexsurv} -\title{Parametric survival regression} -\description{ -\code{\link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg()}} fits a parametric survival model. -} -\details{ -For this engine, there is a single mode: regression -\subsection{Tuning Parameters}{ - -This model has 1 tuning parameters: -\itemize{ -\item \code{dist}: Distribution (type: character, default: ‘weibull’) -} -} - -\subsection{Translation from parsnip to the original package}{ - -\if{html}{\out{
}}\preformatted{surv_reg(dist = character(1)) \%>\% - set_engine("flexsurv") \%>\% - set_mode("regression") \%>\% - translate() -}\if{html}{\out{
}} - -\if{html}{\out{
}}\preformatted{## Parametric Survival Regression Model Specification (regression) -## -## Main Arguments: -## dist = character(1) -## -## Computational engine: flexsurv -## -## Model fit template: -## flexsurv::flexsurvreg(formula = missing_arg(), data = missing_arg(), -## weights = missing_arg(), dist = character(1)) -}\if{html}{\out{
}} -} - -\subsection{Other details}{ - -The main interface for this model uses the formula method since the -model specification typically involved the use of -\code{\link[survival:Surv]{survival::Surv()}}. - -For this engine, stratification cannot be specified via -\code{\link[=strata]{strata()}}, please see -\code{\link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg()}} for alternative -specifications. -} - -\subsection{Saving fitted model objects}{ - -This model object contains data that are not required to make -predictions. When saving the model for the purpose of prediction, the -size of the saved object might be substantially reduced by using -functions from the \href{https://butcher.tidymodels.org}{butcher} package. -} - -\subsection{References}{ -\itemize{ -\item Jackson, C. 2016. \code{flexsurv}: A Platform for Parametric Survival -Modeling in R. \emph{Journal of Statistical Software}, 70(8), 1 - 33. -} -} -} -\keyword{internal} diff --git a/man/details_surv_reg_survival.Rd b/man/details_surv_reg_survival.Rd deleted file mode 100644 index 688df2671..000000000 --- a/man/details_surv_reg_survival.Rd +++ /dev/null @@ -1,91 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/surv_reg_survival.R -\name{details_surv_reg_survival} -\alias{details_surv_reg_survival} -\title{Parametric survival regression} -\description{ -\code{\link[survival:survreg]{survival::survreg()}} fits a parametric survival model. -} -\details{ -For this engine, there is a single mode: regression -\subsection{Tuning Parameters}{ - -This model has 1 tuning parameters: -\itemize{ -\item \code{dist}: Distribution (type: character, default: ‘weibull’) -} -} - -\subsection{Translation from parsnip to the original package}{ - -\if{html}{\out{
}}\preformatted{surv_reg(dist = character(1)) \%>\% - set_engine("survival") \%>\% - set_mode("regression") \%>\% - translate() -}\if{html}{\out{
}} - -\if{html}{\out{
}}\preformatted{## Parametric Survival Regression Model Specification (regression) -## -## Main Arguments: -## dist = character(1) -## -## Computational engine: survival -## -## Model fit template: -## survival::survreg(formula = missing_arg(), data = missing_arg(), -## weights = missing_arg(), dist = character(1), model = TRUE) -}\if{html}{\out{
}} -} - -\subsection{Other details}{ - -Note that \code{model = TRUE} is needed to produce quantile predictions when -there is a stratification variable and can be overridden in other cases. - -The main interface for this model uses the formula method since the -model specification typically involved the use of -\code{\link[survival:Surv]{survival::Surv()}}. - -The model formula can include \emph{special} terms, such as -\code{\link[survival:strata]{survival::strata()}}. The allows the model scale -parameter to differ between groups contained in the function. The column -used inside \code{strata()} is treated as qualitative no matter its type. To -learn more about using special terms in formulas with tidymodels, see -\code{\link[=model_formula]{?model_formula}}. - -For example, in this model, the numeric column \code{rx} is used to estimate -two different scale parameters for each value of the column: - -\if{html}{\out{
}}\preformatted{library(survival) - -surv_reg() \%>\% - fit(Surv(futime, fustat) ~ age + strata(rx), data = ovarian) \%>\% - extract_fit_engine() -}\if{html}{\out{
}} - -\if{html}{\out{
}}\preformatted{## Call: -## survival::survreg(formula = Surv(futime, fustat) ~ age + strata(rx), -## data = data, model = TRUE) -## -## Coefficients: -## (Intercept) age -## 12.8734120 -0.1033569 -## -## Scale: -## rx=1 rx=2 -## 0.7695509 0.4703602 -## -## Loglik(model)= -89.4 Loglik(intercept only)= -97.1 -## Chisq= 15.36 on 1 degrees of freedom, p= 8.88e-05 -## n= 26 -}\if{html}{\out{
}} -} - -\subsection{References}{ -\itemize{ -\item Kalbfleisch, J. D. and Prentice, R. L. 2002 \emph{The statistical analysis -of failure time data}, Wiley. -} -} -} -\keyword{internal} diff --git a/man/glmnet-details.Rd b/man/glmnet-details.Rd index 9a1c6c6fa..f127046ef 100644 --- a/man/glmnet-details.Rd +++ b/man/glmnet-details.Rd @@ -52,7 +52,7 @@ fit <- predict(fit, mtcars[1:3,]) }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## # A tibble: 3 × 1 +\if{html}{\out{
}}\preformatted{## # A tibble: 3 x 1 ## .pred ## ## 1 22.2 @@ -67,12 +67,12 @@ However, any penalty values can be predicted simultaneously using the multi_predict(fit, mtcars[1:3,], penalty = c(0.00, 0.01)) }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## # A tibble: 3 × 1 +\if{html}{\out{
}}\preformatted{## # A tibble: 3 x 1 ## .pred ## -## 1 -## 2 -## 3 +## 1 +## 2 +## 3 }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{# unnested: @@ -81,7 +81,7 @@ multi_predict(fit, mtcars[1:3,], penalty = c(0.00, 0.01)) \%>\% unnest(cols = ".pred") }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## # A tibble: 6 × 3 +\if{html}{\out{
}}\preformatted{## # A tibble: 6 x 3 ## penalty .pred .row ## ## 1 0 22.6 1 @@ -156,7 +156,7 @@ all.equal(sort(fit_ridge$fit$lambda), coef_path_values) predict(fit_ridge, mtcars[1:3,]) }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## # A tibble: 3 × 1 +\if{html}{\out{
}}\preformatted{## # A tibble: 3 x 1 ## .pred ## ## 1 22.1 @@ -180,7 +180,7 @@ originally requested: \if{html}{\out{
}}\preformatted{tidy(fit) }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## # A tibble: 11 × 3 +\if{html}{\out{
}}\preformatted{## # A tibble: 11 x 3 ## term estimate penalty ## ## 1 (Intercept) 35.3 1 @@ -189,7 +189,7 @@ originally requested: ## 4 hp -0.0101 1 ## 5 drat 0 1 ## 6 wt -2.59 1 -## # ℹ 5 more rows +## # i 5 more rows }\if{html}{\out{
}} Note that there is a \code{tidy()} method for \code{glmnet} objects in the \code{broom} @@ -201,7 +201,7 @@ all_tidy_coefs <- broom:::tidy.glmnet(fit$fit) all_tidy_coefs }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## # A tibble: 640 × 5 +\if{html}{\out{
}}\preformatted{## # A tibble: 640 x 5 ## term step estimate lambda dev.ratio ## ## 1 (Intercept) 1 20.1 5.15 0 @@ -210,7 +210,7 @@ all_tidy_coefs ## 4 (Intercept) 4 24.7 3.89 0.347 ## 5 (Intercept) 5 26.0 3.55 0.429 ## 6 (Intercept) 6 27.2 3.23 0.497 -## # ℹ 634 more rows +## # i 634 more rows }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{length(unique(all_tidy_coefs$lambda)) diff --git a/man/mlp.Rd b/man/mlp.Rd index a1d38279b..842de7ab0 100644 --- a/man/mlp.Rd +++ b/man/mlp.Rd @@ -36,8 +36,8 @@ of model parameters randomly set to zero during model training.} \item{activation}{A single character string denoting the type of relationship between the original predictors and the hidden unit layer. The activation function between the hidden and output layers is automatically set to either -"linear" or "softmax" depending on the type of outcome. Possible values are: -"linear", "softmax", "relu", and "elu"} +"linear" or "softmax" depending on the type of outcome. Possible values +depend on the engine being used.} \item{learn_rate}{A number for the rate at which the boosting algorithm adapts from iteration-to-iteration (specific engines only). This is sometimes referred to diff --git a/man/other_predict.Rd b/man/other_predict.Rd index 6000b884a..6c997e28d 100644 --- a/man/other_predict.Rd +++ b/man/other_predict.Rd @@ -8,6 +8,9 @@ \alias{predict_classprob.model_fit} \alias{predict_hazard.model_fit} \alias{predict_confint.model_fit} +\alias{predict_confint} +\alias{predict_predint} +\alias{predict_predint.model_fit} \alias{predict_linear_pred.model_fit} \alias{predict_linear_pred} \alias{predict_numeric.model_fit} @@ -27,6 +30,14 @@ \method{predict_confint}{model_fit}(object, new_data, level = 0.95, std_error = FALSE, ...) +predict_confint(object, ...) + +predict_predint(object, ...) + +\method{predict_predint}{model_fit}(object, new_data, level = 0.95, std_error = FALSE, ...) + +predict_predint(object, ...) + \method{predict_linear_pred}{model_fit}(object, new_data, ...) predict_linear_pred(object, ...) diff --git a/man/parsnip_update.Rd b/man/parsnip_update.Rd index 7cbf4ef0d..51961a67f 100644 --- a/man/parsnip_update.Rd +++ b/man/parsnip_update.Rd @@ -423,8 +423,8 @@ of model parameters randomly set to zero during model training.} \item{activation}{A single character string denoting the type of relationship between the original predictors and the hidden unit layer. The activation function between the hidden and output layers is automatically set to either -"linear" or "softmax" depending on the type of outcome. Possible values are: -"linear", "softmax", "relu", and "elu"} +"linear" or "softmax" depending on the type of outcome. Possible values +depend on the engine being used.} \item{smoothness}{An non-negative number representing the the relative smoothness of the class boundary. Smaller examples result in model flexible diff --git a/man/rmd/aaa.Rmd b/man/rmd/aaa.Rmd index c848e568f..3aa20ac19 100644 --- a/man/rmd/aaa.Rmd +++ b/man/rmd/aaa.Rmd @@ -3,6 +3,7 @@ options(useFancyQuotes = FALSE) options(dplyr.print_min = 6, dplyr.print_max = 6) options(cli.width = 85) +options(cli.unicode = FALSE) options(crayon.enabled = FALSE) options(pillar.min_title_chars = Inf) diff --git a/man/rmd/gen_additive_mod_mgcv.Rmd b/man/rmd/gen_additive_mod_mgcv.Rmd index dddf85839..c1b3c6834 100644 --- a/man/rmd/gen_additive_mod_mgcv.Rmd +++ b/man/rmd/gen_additive_mod_mgcv.Rmd @@ -60,7 +60,7 @@ gen_additive_mod() %>% The smoothness of the terms will need to be manually specified (e.g., using `s(x, df = 10)`) in the formula. Tuning can be accomplished using the `adjust_deg_free` parameter. -When using a workflow, pass the _model formula_ to [add_model()]'s `formula` argument, and a simplified _preprocessing formula_ elsewhere. +When using a workflow, pass the _model formula_ to [workflows::add_model()]'s `formula` argument, and a simplified _preprocessing formula_ elsewhere. ```{r} spec <- diff --git a/man/rmd/gen_additive_mod_mgcv.md b/man/rmd/gen_additive_mod_mgcv.md index ffc84d81a..69b00ca78 100644 --- a/man/rmd/gen_additive_mod_mgcv.md +++ b/man/rmd/gen_additive_mod_mgcv.md @@ -96,7 +96,7 @@ gen_additive_mod() %>% The smoothness of the terms will need to be manually specified (e.g., using `s(x, df = 10)`) in the formula. Tuning can be accomplished using the `adjust_deg_free` parameter. -When using a workflow, pass the _model formula_ to [add_model()]'s `formula` argument, and a simplified _preprocessing formula_ elsewhere. +When using a workflow, pass the _model formula_ to [workflows::add_model()]'s `formula` argument, and a simplified _preprocessing formula_ elsewhere. ```r diff --git a/man/rmd/glmnet-details.md b/man/rmd/glmnet-details.md index ed6c119d2..3c76f8f11 100644 --- a/man/rmd/glmnet-details.md +++ b/man/rmd/glmnet-details.md @@ -34,7 +34,7 @@ predict(fit, mtcars[1:3,]) ``` ``` -## # A tibble: 3 × 1 +## # A tibble: 3 x 1 ## .pred ## ## 1 22.2 @@ -51,12 +51,12 @@ multi_predict(fit, mtcars[1:3,], penalty = c(0.00, 0.01)) ``` ``` -## # A tibble: 3 × 1 +## # A tibble: 3 x 1 ## .pred ## -## 1 -## 2 -## 3 +## 1 +## 2 +## 3 ``` ```r @@ -67,7 +67,7 @@ multi_predict(fit, mtcars[1:3,], penalty = c(0.00, 0.01)) %>% ``` ``` -## # A tibble: 6 × 3 +## # A tibble: 6 x 3 ## penalty .pred .row ## ## 1 0 22.6 1 @@ -138,7 +138,7 @@ predict(fit_ridge, mtcars[1:3,]) ``` ``` -## # A tibble: 3 × 1 +## # A tibble: 3 x 1 ## .pred ## ## 1 22.1 @@ -160,7 +160,7 @@ tidy(fit) ``` ``` -## # A tibble: 11 × 3 +## # A tibble: 11 x 3 ## term estimate penalty ## ## 1 (Intercept) 35.3 1 @@ -169,7 +169,7 @@ tidy(fit) ## 4 hp -0.0101 1 ## 5 drat 0 1 ## 6 wt -2.59 1 -## # ℹ 5 more rows +## # i 5 more rows ``` Note that there is a `tidy()` method for `glmnet` objects in the `broom` package. If this is used directly on the underlying `glmnet` object, it returns _all of coefficients on the path_: @@ -182,7 +182,7 @@ all_tidy_coefs ``` ``` -## # A tibble: 640 × 5 +## # A tibble: 640 x 5 ## term step estimate lambda dev.ratio ## ## 1 (Intercept) 1 20.1 5.15 0 @@ -191,7 +191,7 @@ all_tidy_coefs ## 4 (Intercept) 4 24.7 3.89 0.347 ## 5 (Intercept) 5 26.0 3.55 0.429 ## 6 (Intercept) 6 27.2 3.23 0.497 -## # ℹ 634 more rows +## # i 634 more rows ``` ```r diff --git a/man/rmd/mlp_brulee.md b/man/rmd/mlp_brulee.md index da6084e88..c637678f7 100644 --- a/man/rmd/mlp_brulee.md +++ b/man/rmd/mlp_brulee.md @@ -7,14 +7,12 @@ For this engine, there are multiple modes: classification and regression -This model has 7 tuning parameters: +This model has 6 tuning parameters: - `hidden_units`: # Hidden Units (type: integer, default: 3L) - `penalty`: Amount of Regularization (type: double, default: 0.0) -- `mixture`: Proportion of Lasso Penalty (type: double, default: 0.0) - - `epochs`: # Epochs (type: integer, default: 100L) - `dropout`: Dropout Rate (type: double, default: 0.0) diff --git a/man/rmd/proportional_hazards_glmnet.md b/man/rmd/proportional_hazards_glmnet.md index c294ca1ad..424e33406 100644 --- a/man/rmd/proportional_hazards_glmnet.md +++ b/man/rmd/proportional_hazards_glmnet.md @@ -88,7 +88,7 @@ predict(mod, pred_data, type = "survival", time = 500) %>% ``` ``` -## # A tibble: 2 × 5 +## # A tibble: 2 x 5 ## .eval_time .pred_survival age ecog.ps rx ## ## 1 500 0.666 50 1 1 diff --git a/man/rmd/surv_reg_flexsurv.Rmd b/man/rmd/surv_reg_flexsurv.Rmd deleted file mode 100644 index 2d7202ce5..000000000 --- a/man/rmd/surv_reg_flexsurv.Rmd +++ /dev/null @@ -1,50 +0,0 @@ -```{r, child = "aaa.Rmd", include = FALSE} -``` - -`r descr_models("surv_reg", "survival")` - -## Tuning Parameters - -```{r flexsurv-param-info, echo = FALSE} -defaults <- - tibble::tibble(parsnip = c("dist"), - default = c("'weibull'")) - -param <- - surv_reg() %>% - set_engine("flexsurv") %>% - set_mode("regression") %>% - make_parameter_list(defaults) -``` - -This model has `r nrow(param)` tuning parameters: - -```{r flexsurv-param-list, echo = FALSE, results = "asis"} -param$item -``` - - -## Translation from parsnip to the original package - -```{r flexsurv-reg, warning = FALSE} -surv_reg(dist = character(1)) %>% - set_engine("flexsurv") %>% - set_mode("regression") %>% - translate() -``` - -## Other details - -The main interface for this model uses the formula method since the model specification typically involved the use of [survival::Surv()]. - -For this engine, stratification cannot be specified via [`strata()`], please see [flexsurv::flexsurvreg()] for alternative specifications. - -## Saving fitted model objects - -```{r child = "template-butcher.Rmd"} -``` - - -## References - -- Jackson, C. 2016. `flexsurv`: A Platform for Parametric Survival Modeling in R. _Journal of Statistical Software_, 70(8), 1 - 33. diff --git a/man/rmd/surv_reg_flexsurv.md b/man/rmd/surv_reg_flexsurv.md deleted file mode 100644 index 9aaab07b8..000000000 --- a/man/rmd/surv_reg_flexsurv.md +++ /dev/null @@ -1,52 +0,0 @@ - - - -For this engine, there is a single mode: regression - -## Tuning Parameters - - - -This model has 1 tuning parameters: - -- `dist`: Distribution (type: character, default: 'weibull') - - -## Translation from parsnip to the original package - - -```r -surv_reg(dist = character(1)) %>% - set_engine("flexsurv") %>% - set_mode("regression") %>% - translate() -``` - -``` -## Parametric Survival Regression Model Specification (regression) -## -## Main Arguments: -## dist = character(1) -## -## Computational engine: flexsurv -## -## Model fit template: -## flexsurv::flexsurvreg(formula = missing_arg(), data = missing_arg(), -## weights = missing_arg(), dist = character(1)) -``` - -## Other details - -The main interface for this model uses the formula method since the model specification typically involved the use of [survival::Surv()]. - -For this engine, stratification cannot be specified via [`strata()`], please see [flexsurv::flexsurvreg()] for alternative specifications. - -## Saving fitted model objects - - -This model object contains data that are not required to make predictions. When saving the model for the purpose of prediction, the size of the saved object might be substantially reduced by using functions from the [butcher](https://butcher.tidymodels.org) package. - - -## References - -- Jackson, C. 2016. `flexsurv`: A Platform for Parametric Survival Modeling in R. _Journal of Statistical Software_, 70(8), 1 - 33. diff --git a/man/rmd/surv_reg_survival.Rmd b/man/rmd/surv_reg_survival.Rmd deleted file mode 100644 index fbdb24708..000000000 --- a/man/rmd/surv_reg_survival.Rmd +++ /dev/null @@ -1,55 +0,0 @@ -```{r, child = "aaa.Rmd", include = FALSE} -``` - -`r descr_models("surv_reg", "survival")` - -## Tuning Parameters - -```{r survival-param-info, echo = FALSE} -defaults <- - tibble::tibble(parsnip = c("dist"), - default = c("'weibull'")) - -param <- - surv_reg() %>% - set_engine("survival") %>% - set_mode("regression") %>% - make_parameter_list(defaults) -``` - -This model has `r nrow(param)` tuning parameters: - -```{r survival-param-list, echo = FALSE, results = "asis"} -param$item -``` - -## Translation from parsnip to the original package - -```{r survival-reg, warning = FALSE} -surv_reg(dist = character(1)) %>% - set_engine("survival") %>% - set_mode("regression") %>% - translate() -``` - -## Other details - -Note that `model = TRUE` is needed to produce quantile predictions when there is a stratification variable and can be overridden in other cases. - -The main interface for this model uses the formula method since the model specification typically involved the use of [survival::Surv()]. - -The model formula can include _special_ terms, such as [survival::strata()]. The allows the model scale parameter to differ between groups contained in the function. The column used inside `strata()` is treated as qualitative no matter its type. To learn more about using special terms in formulas with tidymodels, see [`?model_formula`][parsnip::model_formula]. - -For example, in this model, the numeric column `rx` is used to estimate two different scale parameters for each value of the column: - -```{r} -library(survival) - -surv_reg() %>% - fit(Surv(futime, fustat) ~ age + strata(rx), data = ovarian) %>% - extract_fit_engine() -``` - -## References - -- Kalbfleisch, J. D. and Prentice, R. L. 2002 _The statistical analysis of failure time data_, Wiley. diff --git a/man/rmd/surv_reg_survival.md b/man/rmd/surv_reg_survival.md deleted file mode 100644 index 56e7e7765..000000000 --- a/man/rmd/surv_reg_survival.md +++ /dev/null @@ -1,76 +0,0 @@ - - - -For this engine, there is a single mode: regression - -## Tuning Parameters - - - -This model has 1 tuning parameters: - -- `dist`: Distribution (type: character, default: 'weibull') - -## Translation from parsnip to the original package - - -```r -surv_reg(dist = character(1)) %>% - set_engine("survival") %>% - set_mode("regression") %>% - translate() -``` - -``` -## Parametric Survival Regression Model Specification (regression) -## -## Main Arguments: -## dist = character(1) -## -## Computational engine: survival -## -## Model fit template: -## survival::survreg(formula = missing_arg(), data = missing_arg(), -## weights = missing_arg(), dist = character(1), model = TRUE) -``` - -## Other details - -Note that `model = TRUE` is needed to produce quantile predictions when there is a stratification variable and can be overridden in other cases. - -The main interface for this model uses the formula method since the model specification typically involved the use of [survival::Surv()]. - -The model formula can include _special_ terms, such as [survival::strata()]. The allows the model scale parameter to differ between groups contained in the function. The column used inside `strata()` is treated as qualitative no matter its type. To learn more about using special terms in formulas with tidymodels, see [`?model_formula`][parsnip::model_formula]. - -For example, in this model, the numeric column `rx` is used to estimate two different scale parameters for each value of the column: - - -```r -library(survival) - -surv_reg() %>% - fit(Surv(futime, fustat) ~ age + strata(rx), data = ovarian) %>% - extract_fit_engine() -``` - -``` -## Call: -## survival::survreg(formula = Surv(futime, fustat) ~ age + strata(rx), -## data = data, model = TRUE) -## -## Coefficients: -## (Intercept) age -## 12.8734120 -0.1033569 -## -## Scale: -## rx=1 rx=2 -## 0.7695509 0.4703602 -## -## Loglik(model)= -89.4 Loglik(intercept only)= -97.1 -## Chisq= 15.36 on 1 degrees of freedom, p= 8.88e-05 -## n= 26 -``` - -## References - -- Kalbfleisch, J. D. and Prentice, R. L. 2002 _The statistical analysis of failure time data_, Wiley. diff --git a/man/rpart_train.Rd b/man/rpart_train.Rd index 227d55a36..5927233b9 100644 --- a/man/rpart_train.Rd +++ b/man/rpart_train.Rd @@ -46,7 +46,9 @@ those cases.} A fitted rpart model. } \description{ -\code{rpart_train} is a wrapper for \code{rpart()} tree-based models +\code{rpart_train()} is a wrapper for \code{rpart()} tree-based models where all of the model arguments are in the main function. + +The function is now deprecated, as parsnip uses \code{rpart::rpart()} directly. } \keyword{internal}