Skip to content

Commit e4d427e

Browse files
committed
Merge branch 'qrf' of https://github.com/tidymodels/parsnip into qrf
2 parents 7a2cadf + eb5142f commit e4d427e

File tree

10 files changed

+128
-215
lines changed

10 files changed

+128
-215
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
* Enable generalized random forest (`grf`) models for classification, regression, and quantile regression modes. (#1288)
44

5+
* `surv_reg()` is now defunct and will error if called. Please use `survival_reg()` instead (#1206).
6+
7+
58
# parsnip 1.3.3
69

710
* Bug fix in how tunable parameters were configured for brulee neural networks.

R/surv_reg.R

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,37 @@
2727
#' @keywords internal
2828
#' @export
2929
surv_reg <- function(mode = "regression", engine = "survival", dist = NULL) {
30+
lifecycle::deprecate_stop("1.4.0", "surv_reg()", "survival_reg()")
3031

31-
lifecycle::deprecate_warn("0.1.6", "surv_reg()", "survival_reg()")
32-
33-
args <- list(
34-
dist = enquo(dist)
35-
)
36-
37-
new_model_spec(
38-
"surv_reg",
39-
args = args,
40-
eng_args = NULL,
41-
mode = mode,
42-
user_specified_mode = !missing(mode),
43-
method = NULL,
44-
engine = engine,
45-
user_specified_engine = !missing(engine)
46-
)
47-
}
32+
args <- list(
33+
dist = enquo(dist)
34+
)
4835

36+
new_model_spec(
37+
"surv_reg",
38+
args = args,
39+
eng_args = NULL,
40+
mode = mode,
41+
user_specified_mode = !missing(mode),
42+
method = NULL,
43+
engine = engine,
44+
user_specified_engine = !missing(engine)
45+
)
46+
}
47+
48+
# nocov
4949
# ------------------------------------------------------------------------------
5050

5151
#' @method update surv_reg
5252
#' @rdname parsnip_update
5353
#' @export
54-
update.surv_reg <- function(object, parameters = NULL, dist = NULL, fresh = FALSE, ...) {
55-
54+
update.surv_reg <- function(
55+
object,
56+
parameters = NULL,
57+
dist = NULL,
58+
fresh = FALSE,
59+
...
60+
) {
5661
args <- list(
5762
dist = enquo(dist)
5863
)
@@ -84,14 +89,13 @@ translate.surv_reg <- function(x, engine = x$engine, ...) {
8489

8590
#' @export
8691
check_args.surv_reg <- function(object, call = rlang::caller_env()) {
87-
8892
if (object$engine == "flexsurv") {
89-
9093
args <- lapply(object$args, rlang::eval_tidy)
9194

9295
# `dist` has no default in the function
93-
if (all(names(args) != "dist") || is.null(args$dist))
96+
if (all(names(args) != "dist") || is.null(args$dist)) {
9497
object$args$dist <- "weibull"
98+
}
9599
}
96100

97101
invisible(object)
@@ -132,6 +136,11 @@ flexsurv_mean <- function(results, object) {
132136
flexsurv_quant <- function(results, object) {
133137
results <- map(results, as_tibble)
134138
names(results) <- NULL
135-
results <- map(results, setNames, c(".quantile", ".pred", ".pred_lower", ".pred_upper"))
139+
results <- map(
140+
results,
141+
setNames,
142+
c(".quantile", ".pred", ".pred_lower", ".pred_upper")
143+
)
136144
}
137145

146+
# nocov end

R/surv_reg_data.R

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# nocov
12

23
set_new_model("surv_reg")
34
set_model_mode("surv_reg", "regression")
@@ -50,12 +51,11 @@ set_pred(
5051
pre = NULL,
5152
post = flexsurv_mean,
5253
func = c(fun = "summary"),
53-
args =
54-
list(
55-
object = expr(object$fit),
56-
newdata = expr(new_data),
57-
type = "mean"
58-
)
54+
args = list(
55+
object = expr(object$fit),
56+
newdata = expr(new_data),
57+
type = "mean"
58+
)
5959
)
6060
)
6161

@@ -106,11 +106,12 @@ set_pred(
106106
pre = NULL,
107107
post = NULL,
108108
func = c(fun = "predict"),
109-
args =
110-
list(
111-
object = expr(object$fit),
112-
newdata = expr(new_data),
113-
type = "response"
114-
)
109+
args = list(
110+
object = expr(object$fit),
111+
newdata = expr(new_data),
112+
type = "response"
113+
)
115114
)
116115
)
116+
117+
# nocov end

man-roxygen/na_casewise_delete.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#' @section Missing Values:
2+
#' This model silently removes rows with missing values (case-wise deletion) before fitting.

man-roxygen/na_errors.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#' @section Missing Values:
2+
#' This model fails with an error if any rows contain missing values. Missing values should be handled before fitting.

man-roxygen/na_handled.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#' @section Missing Values:
2+
#' This model natively handles missing values during training.

tests/testthat/test-surv_reg.R

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/testthat/test-surv_reg_flexsurv.R

Lines changed: 0 additions & 60 deletions
This file was deleted.

tests/testthat/test-surv_reg_survreg.R

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)