Skip to content

Commit 082351b

Browse files
authored
changes for #1044 (#1231)
1 parent 27df158 commit 082351b

File tree

7 files changed

+5
-141
lines changed

7 files changed

+5
-141
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ export(rand_forest)
312312
export(repair_call)
313313
export(req_pkgs)
314314
export(required_pkgs)
315-
export(rpart_train)
316315
export(rule_fit)
317316
export(set_args)
318317
export(set_dependency)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
* Aligned `null_model()` with other model types; the model type now has an engine argument that defaults to `"parsnip"` and is checked with the same machinery that checks other model types in the package (#1083).
2525

26+
* The deprecated function `rpart_train()` was removed after its deprecation period (#1044).
27+
2628
## Bug Fixes
2729

2830
* Make sure that parsnip does not convert ordered factor predictions to be unordered.

R/decision_tree.R

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -129,76 +129,3 @@ translate.decision_tree <- function(x, engine = x$engine, ...) {
129129
check_args.decision_tree <- function(object, call = rlang::caller_env()) {
130130
invisible(object)
131131
}
132-
133-
# ------------------------------------------------------------------------------
134-
135-
#' Decision trees via rpart
136-
#'
137-
#' @description
138-
#' `rpart_train()` is a wrapper for `rpart()` tree-based models
139-
#' where all of the model arguments are in the main function.
140-
#'
141-
#' The function is now deprecated, as parsnip uses `rpart::rpart()` directly.
142-
#'
143-
#' @param formula A model formula.
144-
#' @param data A data frame.
145-
#' @param cp A non-negative number for complexity parameter. Any split
146-
#' that does not decrease the overall lack of fit by a factor of
147-
#' `cp` is not attempted. For instance, with anova splitting,
148-
#' this means that the overall R-squared must increase by `cp` at
149-
#' each step. The main role of this parameter is to save computing
150-
#' time by pruning off splits that are obviously not worthwhile.
151-
#' Essentially, the user informs the program that any split which
152-
#' does not improve the fit by `cp` will likely be pruned off by
153-
#' cross-validation, and that hence the program need not pursue it.
154-
#' @param weights Optional case weights.
155-
#' @param minsplit An integer for the minimum number of observations
156-
#' that must exist in a node in order for a split to be attempted.
157-
#' @param maxdepth An integer for the maximum depth of any node
158-
#' of the final tree, with the root node counted as depth 0.
159-
#' Values greater than 30 `rpart` will give nonsense results on
160-
#' 32-bit machines. This function will truncate `maxdepth` to 30 in
161-
#' those cases.
162-
#' @param ... Other arguments to pass to either `rpart` or `rpart.control`.
163-
#' @return A fitted rpart model.
164-
#' @keywords internal
165-
#' @export
166-
rpart_train <-
167-
function(formula, data, weights = NULL, cp = 0.01, minsplit = 20, maxdepth = 30, ...) {
168-
lifecycle::deprecate_warn(
169-
"1.2.0",
170-
"rpart_train()",
171-
details = 'Instead, use `decision_tree(engine = "rpart")` or `rpart::rpart()` directly.'
172-
)
173-
174-
bitness <- 8 * .Machine$sizeof.pointer
175-
if (bitness == 32 & maxdepth > 30)
176-
maxdepth <- 30
177-
178-
other_args <- list(...)
179-
protect_ctrl <- c("minsplit", "maxdepth", "cp")
180-
protect_fit <- NULL
181-
f_names <- names(formals(getFromNamespace("rpart", "rpart")))
182-
c_names <- names(formals(getFromNamespace("rpart.control", "rpart")))
183-
other_args <- other_args[!(other_args %in% c(protect_ctrl, protect_fit))]
184-
ctrl_args <- other_args[names(other_args) %in% c_names]
185-
fit_args <- other_args[names(other_args) %in% f_names]
186-
187-
ctrl <- call2("rpart.control", .ns = "rpart")
188-
ctrl$minsplit <- minsplit
189-
ctrl$maxdepth <- maxdepth
190-
ctrl$cp <- cp
191-
ctrl <- rlang::call_modify(ctrl, !!!ctrl_args)
192-
193-
fit_call <- call2("rpart", .ns = "rpart")
194-
fit_call$formula <- expr(formula)
195-
fit_call$data <- expr(data)
196-
fit_call$control <- ctrl
197-
if (!is.null(weights)) {
198-
fit_call$weights <- quote(weights)
199-
}
200-
fit_call <- rlang::call_modify(fit_call, !!!fit_args)
201-
202-
eval_tidy(fit_call)
203-
}
204-

R/misc.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ is_cran_check <- function() {
602602
}
603603

604604
if (inherits(x, "workflow")) {
605-
x <- x %>% extract_fit_parsnip(x)
605+
x <- x %>% hardhat::extract_fit_parsnip(x)
606606
}
607607
model_spec <- extract_spec_parsnip(x)
608608
model_engine <- model_spec$engine

man/dot-get_prediction_column_names.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rpart_train.Rd

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

tests/testthat/test-decision_tree.R

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ test_that('bad input', {
2525
)
2626
})
2727

28-
test_that('rpart_train is stop-deprecated when it ought to be (#1044)', {
29-
skip_on_cran()
30-
31-
# once this test fails, transition `rpart_train()` to `deprecate_stop()`
32-
# and transition this test to fail if `rpart_train()` still exists after a year.
33-
if (Sys.Date() > "2025-01-01") {
34-
expect_snapshot(error = TRUE, rpart_train(mpg ~ ., mtcars))
35-
}
36-
})
37-
3828
# ------------------------------------------------------------------------------
3929

4030
test_that('argument checks for data dimensions', {

0 commit comments

Comments
 (0)