Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
Merge branch 'main' into spark-1045

# Conflicts:
#	NEWS.md
  • Loading branch information
simonpcouch committed Jan 16, 2024
2 parents d12ee60 + 948308b commit cb66545
Show file tree
Hide file tree
Showing 43 changed files with 229 additions and 136 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: parsnip
Title: A Common API to Modeling and Analysis Functions
Version: 1.1.1.9003
Version: 1.1.1.9007
Authors@R: c(
person("Max", "Kuhn", , "[email protected]", role = c("aut", "cre")),
person("Davis", "Vaughan", , "[email protected]", role = "aut"),
Expand Down Expand Up @@ -76,4 +76,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3.9000
RoxygenNote: 7.2.3
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

S3method(.censoring_weights_graf,default)
S3method(.censoring_weights_graf,model_fit)
S3method(.censoring_weights_graf,workflow)
S3method(augment,model_fit)
S3method(autoplot,glmnet)
S3method(autoplot,model_fit)
Expand Down Expand Up @@ -179,6 +178,7 @@ export(bag_tree)
export(bart)
export(bartMachine_interval_calc)
export(boost_tree)
export(case_weights_allowed)
export(cforest_train)
export(check_empty_ellipse)
export(check_final_param)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Fixed bug in fitting some model types with the `"spark"` engine (#1045).

* `.filter_eval_time()` was moved to the survival standalone file.

* Improved errors and documentation related to special terms in formulas. See `?model_formula` to learn more. (#770, #1014)

* Improved errors in cases where the outcome column is mis-specified. (#1003)
Expand All @@ -12,6 +14,10 @@

* When computing censoring weights, the resulting vectors are no longer named (#1023).

* Fixed a bug in the integration with workflows where using a model formula with a formula preprocessor could result in a double intercept (#1033).

* The `predict()` method for `censoring_model_reverse_km` objects now checks that `...` are empty (#1029).

# parsnip 1.1.1

* Fixed bug where prediction on rank deficient `lm()` models produced `.pred_res` instead of `.pred`. (#985)
Expand Down
1 change: 1 addition & 0 deletions R/bag_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams decision_tree
#' @param class_cost A non-negative scalar for a class cost (where a cost of 1
#' means no extra cost). This is useful for when the first level of the outcome
Expand Down
1 change: 1 addition & 0 deletions R/bart.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams nearest_neighbor
#' @inheritParams boost_tree
#' @param prior_terminal_node_coef A coefficient for the prior probability that
#' a node is a terminal node. Values are usually between 0 and one with
Expand Down
4 changes: 2 additions & 2 deletions R/boost_tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#' \url{https://www.tidymodels.org/}.
#'
#' @param mode A single character string for the prediction outcome mode.
#' Possible values for this model are "unknown", "regression", or
#' "classification".
#' Possible values for this model are "unknown", "regression",
#' "classification", or "censored regression".
#' @param engine A single character string specifying what computational engine
#' to use for fitting.
#' @param mtry A number for the number (or proportion) of predictors that will
Expand Down
2 changes: 1 addition & 1 deletion R/c5_rules.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @param mode A single character string for the type of model.
#' The only possible value for this model is "classification".
#' @param trees A non-negative integer (no greater than 100) for the number
Expand Down
11 changes: 11 additions & 0 deletions R/case_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ patch_formula_environment_with_case_weights <- function(formula,

# ------------------------------------------------------------------------------

#' Determine if case weights are used
#'
#' Not all modeling engines can incorporate case weights into their
#' calculations. This function can determine whether they can be used.
#'
#' @param spec A parsnip model specification.
#' @return A single logical.
#' @examples
#' case_weights_allowed(linear_reg())
#' case_weights_allowed(linear_reg(engine = "keras"))
#' @export
case_weights_allowed <- function(spec) {
mod_type <- class(spec)[1]
mod_eng <- spec$engine
Expand Down
4 changes: 4 additions & 0 deletions R/convert_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
rlang::abort("`composition` should be either 'data.frame' or 'matrix'.")
}

if (remove_intercept) {
data <- data[, colnames(data) != "(Intercept)", drop = FALSE]
}

## Assemble model.frame call from call arguments
mf_call <- quote(model.frame(formula, data))
mf_call$na.action <- match.call()$na.action # TODO this should work better
Expand Down
2 changes: 1 addition & 1 deletion R/cubist_rules.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @param mode A single character string for the type of model.
#' The only possible value for this model is "regression".
#' @param committees A non-negative integer (no greater than 100) for the number
Expand Down
2 changes: 1 addition & 1 deletion R/discrim_flexible.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @inheritParams discrim_linear
#' @param num_terms The number of features that will be retained in the
#' final model, including the intercept.
Expand Down
2 changes: 1 addition & 1 deletion R/discrim_linear.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @param mode A single character string for the type of model. The only
#' possible value for this model is "classification".
#' @param penalty An non-negative number representing the amount of
Expand Down
2 changes: 1 addition & 1 deletion R/discrim_quad.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @param mode A single character string for the type of model. The only
#' possible value for this model is "classification".
#' @param regularization_method A character string for the type of regularized
Expand Down
2 changes: 1 addition & 1 deletion R/discrim_regularized.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @inheritParams discrim_linear
#' @param frac_common_cov,frac_identity Numeric values between zero and one.
#'
Expand Down
9 changes: 9 additions & 0 deletions R/fit_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ form_form <-

if (inherits(env$data, "data.frame")) {
check_outcome(eval_tidy(rlang::f_lhs(env$formula), env$data), object)

encoding_info <-
get_encoding(class(object)[1]) %>%
dplyr::filter(mode == object$mode, engine == object$engine)

remove_intercept <- encoding_info %>% dplyr::pull(remove_intercept)
if (remove_intercept) {
env$data <- env$data[, colnames(env$data) != "(Intercept)", drop = FALSE]
}
}

# prob rewrite this as simple subset/levels
Expand Down
2 changes: 1 addition & 1 deletion R/gen_additive_mod.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @param select_features `TRUE` or `FALSE.` If `TRUE`, the model has the
#' ability to eliminate a predictor (via penalization). Increasing
#' `adjust_deg_free` will increase the likelihood of removing predictors.
Expand Down
2 changes: 1 addition & 1 deletion R/mars.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @param num_terms The number of features that will be retained in the
#' final model, including the intercept.
#' @param prod_degree The highest possible interaction degree.
Expand Down
1 change: 1 addition & 0 deletions R/mlp.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams nearest_neighbor
#' @inheritParams boost_tree
#' @param hidden_units An integer for the number of units in the hidden model.
#' @param penalty A non-negative numeric value for the amount of weight
Expand Down
2 changes: 1 addition & 1 deletion R/naive_Bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @inheritParams discrim_linear
#' @param smoothness An non-negative number representing the the relative
#' smoothness of the class boundary. Smaller examples result in model flexible
Expand Down
6 changes: 5 additions & 1 deletion R/nearest_neighbor.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @param mode A single character string for the prediction outcome mode.
#' Possible values for this model are "unknown", "regression", or
#' "classification".
#' @param engine A single character string specifying what computational engine
#' to use for fitting.
#' @param neighbors A single integer for the number of neighbors
#' to consider (often called `k`). For \pkg{kknn}, a value of 5
#' is used if `neighbors` is not specified.
Expand Down
2 changes: 1 addition & 1 deletion R/pls.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @param predictor_prop The maximum proportion of original predictors that can
#' have _non-zero_ coefficients for each PLS component (via regularization).
#' This value is used for all PLS components for X.
Expand Down
2 changes: 1 addition & 1 deletion R/poisson_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @param mode A single character string for the type of model.
#' The only possible value for this model is "regression".
#' @param penalty A non-negative number representing the total
Expand Down
2 changes: 1 addition & 1 deletion R/proportional_hazards.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams boost_tree
#' @inheritParams nearest_neighbor
#' @inheritParams linear_reg
#' @param mode A single character string for the prediction outcome mode.
#' The only possible value for this model is "censored regression".
Expand Down
1 change: 1 addition & 0 deletions R/rule_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' More information on how \pkg{parsnip} is used for modeling is at
#' \url{https://www.tidymodels.org/}.
#'
#' @inheritParams nearest_neighbor
#' @inheritParams boost_tree
#' @param penalty L1 regularization parameter.
#' @details
Expand Down
Loading

0 comments on commit cb66545

Please sign in to comment.