Skip to content

Commit b05d93c

Browse files
authored
Merge pull request #169 from tidymodels/default-engine
Default engine changes for #166
2 parents 93ec73f + 7c5c0bc commit b05d93c

33 files changed

+134
-71
lines changed

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# parsnip 0.0.2.9000
2+
3+
## New Features
4+
5+
* `add_rowindex()` can create a column called `.row` to a data frame.
6+
7+
* If a computational engine is not explicitly set, a default will be used. Each default is documented on the corresponding model page. A warning is issued at fit time unless verbosity is zero.
8+
9+
110
# parsnip 0.0.2
211

312
Small release driven by changes in `sample()` in the current r-devel.

R/boost_tree.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#' The model can be created using the `fit()` function using the
5555
#' following _engines_:
5656
#' \itemize{
57-
#' \item \pkg{R}: `"xgboost"`, `"C5.0"`
57+
#' \item \pkg{R}: `"xgboost"` (the default), `"C5.0"`
5858
#' \item \pkg{Spark}: `"spark"`
5959
#' }
6060
#'

R/decision_tree.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#' The model can be created using the `fit()` function using the
3535
#' following _engines_:
3636
#' \itemize{
37-
#' \item \pkg{R}: `"rpart"` or `"C5.0"` (classification only)
37+
#' \item \pkg{R}: `"rpart"` (the default) or `"C5.0"` (classification only)
3838
#' \item \pkg{Spark}: `"spark"`
3939
#' }
4040
#'

R/fit.R

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#' the data are converted to the required format. In this case, any
4040
#' calls in the resulting model objects reference the temporary
4141
#' objects used to fit the model.
42+
#'
43+
#' If the model engine has not been set, the model's default engine will be used
44+
#' (as discussed on each model page). If the `verbosity` option of
45+
#' [fit_control()] is greater than zero, a warning will be produced.
4246
#' @examples
4347
#' # Although `glm()` only has a formula interface, different
4448
#' # methods for specifying the model can be used
@@ -93,8 +97,13 @@ fit.model_spec <-
9397
...
9498
) {
9599
dots <- quos(...)
96-
if (any(names(dots) == "engine"))
97-
stop("Use `set_engine()` to supply the engine.", call. = FALSE)
100+
if (is.null(object$engine)) {
101+
eng_vals <- possible_engines(object)
102+
object$engine <- eng_vals[1]
103+
if (control$verbosity > 0) {
104+
warning("Engine set to `", object$engine, "`", call. = FALSE)
105+
}
106+
}
98107

99108
if (all(c("x", "y") %in% names(dots)))
100109
stop("`fit.model_spec()` is for the formula methods. Use `fit_xy()` instead.",
@@ -177,8 +186,13 @@ fit_xy.model_spec <-
177186
...
178187
) {
179188
dots <- quos(...)
180-
if (any(names(dots) == "engine"))
181-
stop("Use `set_engine()` to supply the engine.", call. = FALSE)
189+
if (is.null(object$engine)) {
190+
eng_vals <- possible_engines(object)
191+
object$engine <- eng_vals[1]
192+
if (control$verbosity > 0) {
193+
warning("Engine set to `", object$engine, "`", call. = FALSE)
194+
}
195+
}
182196

183197
if (object$engine != "spark" & NCOL(y) == 1 & !(is.vector(y) | is.factor(y))) {
184198
if (is.matrix(y)) {

R/linear_reg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#' The model can be created using the `fit()` function using the
3737
#' following _engines_:
3838
#' \itemize{
39-
#' \item \pkg{R}: `"lm"` or `"glmnet"`
39+
#' \item \pkg{R}: `"lm"` (the default) or `"glmnet"`
4040
#' \item \pkg{Stan}: `"stan"`
4141
#' \item \pkg{Spark}: `"spark"`
4242
#' \item \pkg{keras}: `"keras"`

R/logistic_reg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#' The model can be created using the `fit()` function using the
3535
#' following _engines_:
3636
#' \itemize{
37-
#' \item \pkg{R}: `"glm"` or `"glmnet"`
37+
#' \item \pkg{R}: `"glm"` (the default) or `"glmnet"`
3838
#' \item \pkg{Stan}: `"stan"`
3939
#' \item \pkg{Spark}: `"spark"`
4040
#' \item \pkg{keras}: `"keras"`

R/mars.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#' @details The model can be created using the `fit()` function using the
3434
#' following _engines_:
3535
#' \itemize{
36-
#' \item \pkg{R}: `"earth"`
36+
#' \item \pkg{R}: `"earth"` (the default)
3737
#' }
3838
#'
3939
#' @section Engine Details:

R/mlp.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#' The model can be created using the `fit()` function using the
4848
#' following _engines_:
4949
#' \itemize{
50-
#' \item \pkg{R}: `"nnet"`
50+
#' \item \pkg{R}: `"nnet"` (the default)
5151
#' \item \pkg{keras}: `"keras"`
5252
#' }
5353
#'

R/multinom_reg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#' The model can be created using the `fit()` function using the
3535
#' following _engines_:
3636
#' \itemize{
37-
#' \item \pkg{R}: `"glmnet"`
37+
#' \item \pkg{R}: `"glmnet"` (the default)
3838
#' \item \pkg{Stan}: `"stan"`
3939
#' \item \pkg{keras}: `"keras"`
4040
#' }

R/nearest_neighbor.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#' The model can be created using the `fit()` function using the
4444
#' following _engines_:
4545
#' \itemize{
46-
#' \item \pkg{R}: `"kknn"`
46+
#' \item \pkg{R}: `"kknn"` (the default)
4747
#' }
4848
#'
4949
#' @section Engine Details:

0 commit comments

Comments
 (0)