Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* The helper functions `.convert_form_to_xy_fit()`, `.convert_form_to_xy_new()`, `.convert_xy_to_form_fit()`, and `.convert_xy_to_form_new()` for converting between formula and matrix interface are now exported for developer use (#508).

* Fix bug in `augment()` when non-predictor, non-outcome variables are included in data (#510).

# parsnip 0.1.6

## Model Specification Changes
Expand All @@ -19,7 +21,6 @@

* For xgboost, `mtry` and `colsample_bytree` can be passed as integer counts or proportions, while `subsample` and `validation` should always be proportions. `xgb_train()` now has a new option `counts` (`TRUE` or `FALSE`) that states which scale for `mtry` and `colsample_bytree` is being used. (#461)

r
## Other Changes

* Re-licensed package from GPL-2 to MIT. See [consent from copyright holders here](https://github.com/tidymodels/parsnip/issues/462).
Expand Down
17 changes: 9 additions & 8 deletions R/augment.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,35 @@
#' augment(cls_xy, cls_tst[, -3])
#'
augment.model_fit <- function(x, new_data, ...) {
ret <- new_data
if (x$spec$mode == "regression") {
check_spec_pred_type(x, "numeric")
new_data <-
new_data %>%
ret <-
ret %>%
dplyr::bind_cols(
predict(x, new_data = new_data)
)
if (length(x$preproc$y_var) > 0) {
y_nm <- x$preproc$y_var
if (any(names(new_data) == y_nm)) {
new_data <- dplyr::mutate(new_data, .resid = !!rlang::sym(y_nm) - .pred)
ret <- dplyr::mutate(ret, .resid = !!rlang::sym(y_nm) - .pred)
}
}
} else if (x$spec$mode == "classification") {
if (spec_has_pred_type(x, "class")) {
new_data <- dplyr::bind_cols(
new_data,
ret <- dplyr::bind_cols(
ret,
predict(x, new_data = new_data, type = "class")
)
}
if (spec_has_pred_type(x, "prob")) {
new_data <- dplyr::bind_cols(
new_data,
ret <- dplyr::bind_cols(
ret,
predict(x, new_data = new_data, type = "prob")
)
}
} else {
rlang::abort(paste("Unknown mode:", x$spec$mode))
}
as_tibble(new_data)
as_tibble(ret)
}