Skip to content

Commit

Permalink
Merge pull request #230 from tidymodels/control-parsnip
Browse files Browse the repository at this point in the history
new control function name
  • Loading branch information
topepo authored Nov 1, 2019
2 parents 976567f + 7208825 commit 52d9f77
Show file tree
Hide file tree
Showing 126 changed files with 1,750 additions and 1,529 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: parsnip
Version: 0.0.3.9002
Version: 0.0.4
Title: A Common API to Modeling and Analysis Functions
Description: A common interface is provided to allow users to specify a model without having to remember the different argument names across different functions or computational engines (e.g. 'R', 'Spark', 'Stan', etc).
Authors@R: c(
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ S3method(predict_raw,"_elnet")
S3method(predict_raw,"_lognet")
S3method(predict_raw,"_multnet")
S3method(print,boost_tree)
S3method(print,control_parsnip)
S3method(print,decision_tree)
S3method(print,fit_control)
S3method(print,linear_reg)
S3method(print,logistic_reg)
S3method(print,mars)
Expand Down Expand Up @@ -90,6 +90,7 @@ export(C5.0_train)
export(add_rowindex)
export(boost_tree)
export(check_empty_ellipse)
export(control_parsnip)
export(decision_tree)
export(fit)
export(fit.model_spec)
Expand Down
15 changes: 8 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# parsnip 0.0.3.9001
# parsnip 0.0.4

## New Features

* The time elapsed during model fitting is stored in the `$elapsed` slot of the
parsnip model object, and is printed when the model object is printed.
* The time elapsed during model fitting is stored in the `$elapsed` slot of the parsnip model object, and is printed when the model object is printed.

* Some default parameter ranges were updated for SVM, KNN, and MARS models.

* The model `udpate()` methods gained a `parameters` argument for cases when the parameters are contained in a tibble or list.

* `fit_control()` is soft-deprecated in favor of `control_parsnip()`.

## Fixes
* [A bug](https://github.com/tidymodels/parsnip/issues/222) was fixed standardizing
the output column types of `multi_predict` and `predict` for `multinom_reg`.

* [A bug](https://github.com/tidymodels/parsnip/issues/222) was fixed standardizing the output column types of `multi_predict` and `predict` for `multinom_reg`.

* [A bug](https://github.com/tidymodels/parsnip/issues/208) was fixed related to using data descriptors and `fit_xy()`.

* A bug was fixed related to the column names generated by `multi_predict()`. The top-level tibble will always have a column named `.pred` and this list column contains tibbles across sub-models. The column names for these sub-model tibbles will have names consistent with `predict()` (which was previously incorrect). See [43c15db](https://github.com/tidymodels/parsnip/commit/43c15db377ea9ef27483ff209f6bd0e98cb830d2).

* The model `udpate()` methods gained a `parameters` argument for cases when the parameters are contained in a tibble or list.

* [A bug](https://github.com/tidymodels/parsnip/issues/174) was fixed standardizing the column names of `nnet` class probability predictions.


Expand Down
2 changes: 1 addition & 1 deletion R/boost_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#' reloaded and reattached to the `parsnip` object.
#'
#' @importFrom purrr map_lgl
#' @seealso [varying()], [fit()], [set_engine()]
#' @seealso [[fit()], [set_engine()]
#' @examples
#' boost_tree(mode = "classification", trees = 20)
#' # Parameters can be represented by a placeholder:
Expand Down
15 changes: 11 additions & 4 deletions R/fit_control.R → R/control_parsnip.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@
#' class "try-error".
#' @return An S3 object with class "fit_control" that is a named list with the
#' results of the function call
#' @details
#' `fit_control()` is deprecated in favor of `control_parsnip()`.
#' @export
#'

fit_control <- function(verbosity = 1L, catch = FALSE) {
control_parsnip <- function(verbosity = 1L, catch = FALSE) {
res <- list(verbosity = verbosity, catch = catch)
res <- check_control(res)
class(res) <- "fit_control"
class(res) <- "control_parsnip"
res
}

#' @export
print.fit_control <- function(x, ...) {
#' @rdname control_parsnip
fit_control <- function(verbosity = 1L, catch = FALSE) {
control_parsnip(verbosity = verbosity, catch = catch)
}

#' @export
print.control_parsnip <- function(x, ...) {
cat("parsnip control object\n")
if (x$verbosity > 1)
cat(" - verbose level", x$verbosity, "\n")
Expand Down
2 changes: 1 addition & 1 deletion R/decision_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
#' reloaded and reattached to the `parsnip` object.
#'
#' @importFrom purrr map_lgl
#' @seealso [varying()], [fit()]
#' @seealso [[fit()]
#' @examples
#' decision_tree(mode = "classification", tree_depth = 5)
#' # Parameters can be represented by a placeholder:
Expand Down
10 changes: 5 additions & 5 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' outcome(s), predictors, case weights, etc). Note: when needed, a
#' \emph{named argument} should be used.
#' @param control A named list with elements `verbosity` and
#' `catch`. See [fit_control()].
#' `catch`. See [control_parsnip()].
#' @param ... Not currently used; values passed here will be
#' ignored. Other options required to fit the model should be
#' passed using `set_engine()`.
Expand All @@ -42,7 +42,7 @@
#'
#' If the model engine has not been set, the model's default engine will be used
#' (as discussed on each model page). If the `verbosity` option of
#' [fit_control()] is greater than zero, a warning will be produced.
#' [control_parsnip()] is greater than zero, a warning will be produced.
#' @examples
#' # Although `glm()` only has a formula interface, different
#' # methods for specifying the model can be used
Expand Down Expand Up @@ -81,7 +81,7 @@
#' The return value will also have a class related to the fitted model (e.g.
#' `"_glm"`) before the base class of `"model_fit"`.
#'
#' @seealso [set_engine()], [fit_control()], `model_spec`, `model_fit`
#' @seealso [set_engine()], [control_parsnip()], `model_spec`, `model_fit`
#' @param x A matrix or data frame of predictors.
#' @param y A vector, matrix or data frame of outcome data.
#' @rdname fit
Expand All @@ -91,7 +91,7 @@ fit.model_spec <-
function(object,
formula = NULL,
data = NULL,
control = fit_control(),
control = control_parsnip(),
...
) {
if (object$mode == "unknown") {
Expand Down Expand Up @@ -182,7 +182,7 @@ fit_xy.model_spec <-
function(object,
x = NULL,
y = NULL,
control = fit_control(),
control = control_parsnip(),
...
) {
object <- check_mode(object, levels(y))
Expand Down
2 changes: 1 addition & 1 deletion R/linear_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
#' separately saved to disk. In a new session, the object can be
#' reloaded and reattached to the `parsnip` object.
#'
#' @seealso [varying()], [fit()], [set_engine()]
#' @seealso [[fit()], [set_engine()]
#' @examples
#' linear_reg()
#' # Parameters can be represented by a placeholder:
Expand Down
2 changes: 1 addition & 1 deletion R/logistic_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
#' separately saved to disk. In a new session, the object can be
#' reloaded and reattached to the `parsnip` object.
#'
#' @seealso [varying()], [fit()]
#' @seealso [[fit()]
#' @examples
#' logistic_reg()
#' # Parameters can be represented by a placeholder:
Expand Down
2 changes: 1 addition & 1 deletion R/mars.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#' attached.
#'
#' @importFrom purrr map_lgl
#' @seealso [varying()], [fit()]
#' @seealso [[fit()]
#' @examples
#' mars(mode = "regression", num_terms = 5)
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/mlp.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
#' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::mlp(mode = "regression"), "nnet")}
#'
#' @importFrom purrr map_lgl
#' @seealso [varying()], [fit()]
#' @seealso [[fit()]
#' @examples
#' mlp(mode = "classification", penalty = 0.01)
#' # Parameters can be represented by a placeholder:
Expand Down
2 changes: 1 addition & 1 deletion R/multinom_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
#' separately saved to disk. In a new session, the object can be
#' reloaded and reattached to the `parsnip` object.
#'
#' @seealso [varying()], [fit()]
#' @seealso [[fit()]
#' @examples
#' multinom_reg()
#' # Parameters can be represented by a placeholder:
Expand Down
2 changes: 1 addition & 1 deletion R/nearest_neighbor.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#' on new data. This also means that a single value of that function's
#' `kernel` argument (a.k.a `weight_func` here) can be supplied
#'
#' @seealso [varying()], [fit()]
#' @seealso [[fit()]
#'
#' @examples
#' nearest_neighbor(neighbors = 11)
Expand Down
2 changes: 1 addition & 1 deletion R/nullmodel.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ predict.nullmodel <- function (object, new_data = NULL, type = NULL, ...) {
#' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::null_model(mode = "regression"), "parsnip")}
#'
#' @importFrom purrr map_lgl
#' @seealso [varying()], [fit()]
#' @seealso [fit()]
#' @examples
#' null_model(mode = "regression")
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/rand_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#' reloaded and reattached to the `parsnip` object.
#'
#' @importFrom purrr map_lgl
#' @seealso [varying()], [fit()]
#' @seealso [[fit()]
#' @examples
#' rand_forest(mode = "classification", trees = 2000)
#' # Parameters can be represented by a placeholder:
Expand Down
2 changes: 1 addition & 1 deletion R/surv_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#' predictions when there is a stratification variable and can be
#' overridden in other cases.
#'
#' @seealso [varying()], [fit()], [survival::Surv()]
#' @seealso [[fit()], [survival::Surv()]
#' @references Jackson, C. (2016). `flexsurv`: A Platform for Parametric Survival
#' Modeling in R. _Journal of Statistical Software_, 70(8), 1 - 33.
#' @examples
Expand Down
2 changes: 1 addition & 1 deletion R/svm_poly.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::svm_poly(mode = "regression"), "kernlab")}
#'
#' @importFrom purrr map_lgl
#' @seealso [varying()], [fit()]
#' @seealso [[fit()]
#' @examples
#' svm_poly(mode = "classification", degree = 1.2)
#' # Parameters can be represented by a placeholder:
Expand Down
2 changes: 1 addition & 1 deletion R/svm_rbf.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::svm_rbf(mode = "regression"), "kernlab")}
#'
#' @importFrom purrr map_lgl
#' @seealso [varying()], [fit()]
#' @seealso [fit()]
#' @examples
#' svm_rbf(mode = "classification", rbf_sigma = 0.2)
#' # Parameters can be represented by a placeholder:
Expand Down
31 changes: 16 additions & 15 deletions docs/dev/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 52d9f77

Please sign in to comment.