Skip to content

Commit

Permalink
Don't coerce sparse data to non-sparse during predict() (#950)
Browse files Browse the repository at this point in the history
* pass sparse data through prepare_data()

* add news

* move news bullet to devel

---------

Co-authored-by: Max Kuhn <[email protected]>
  • Loading branch information
EmilHvitfeldt and topepo authored May 17, 2023
1 parent fe721f6 commit 145bac2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# parsnip (development version)

* Fixed bug where sparse data was being coerced to non-sparse format doing `predict()`.

* `augment()` now works for censored regression models.

# parsnip 1.1.0
Expand Down
4 changes: 4 additions & 0 deletions R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ prepare_data <- function(object, new_data) {
new_data <- new_data[, colnames(new_data) != "(Intercept)", drop = FALSE]
}

if (allow_sparse(object) && inherits(new_data, "dgCMatrix")) {
return(new_data)
}

fit_interface <- object$spec$method$fit$interface
switch(
fit_interface,
Expand Down

0 comments on commit 145bac2

Please sign in to comment.