Skip to content

Commit fddc746

Browse files
authored
Merge pull request #833 from tidymodels/move-fit_xy.decision_tree
add `fit_xy.decision_tree()`
2 parents 025cc59 + d018e2a commit fddc746

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: parsnip
22
Title: A Common API to Modeling and Analysis Functions
3-
Version: 1.0.2.9001
3+
Version: 1.0.2.9002
44
Authors@R: c(
55
person("Max", "Kuhn", , "[email protected]", role = c("aut", "cre")),
66
person("Davis", "Vaughan", , "[email protected]", role = "aut"),

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ S3method(extract_parameter_dials,model_spec)
66
S3method(extract_parameter_set_dials,model_spec)
77
S3method(extract_spec_parsnip,model_fit)
88
S3method(fit,model_spec)
9+
S3method(fit_xy,decision_tree)
910
S3method(fit_xy,gen_additive_mod)
1011
S3method(fit_xy,model_spec)
1112
S3method(glance,model_fit)

R/decision_tree.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,27 @@ check_args.decision_tree <- function(object) {
134134

135135
# ------------------------------------------------------------------------------
136136

137+
#' @export
138+
fit_xy.decision_tree <- function(object,
139+
x,
140+
y,
141+
case_weights = NULL,
142+
control = parsnip::control_parsnip(),
143+
...) {
144+
145+
if (object$mode == "censored regression" && object$engine == "rpart") {
146+
# prodlim::EventHistory.frame() expects a call to `Surv()` (or `Hist()`) on
147+
# the left-hand side of the formula
148+
rlang::abort("For the `'rpart'` engine, please use the formula interface via `fit()`.")
149+
}
150+
151+
# call parsnip::fit_xy.model_spec()
152+
res <- NextMethod()
153+
res
154+
}
155+
156+
# ------------------------------------------------------------------------------
157+
137158
#' Decision trees via rpart
138159
#'
139160
#' `rpart_train` is a wrapper for `rpart()` tree-based models

0 commit comments

Comments
 (0)