Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a recipe has a ptype, use it to set up the vetiver model #287

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Suggests:
plotly,
plumber (>= 1.0.0),
ranger,
recipes,
recipes (>= 1.1.0),
reticulate,
rmarkdown,
rpart,
Expand Down
7 changes: 2 additions & 5 deletions R/recipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ vetiver_create_meta.recipe <- function(model, metadata) {
#' @rdname vetiver_create_ptype
#' @export
vetiver_ptype.recipe <- function(model, ...) {
rlang::check_dots_used()
dots <- list(...)
check_ptype_data(dots)
ptype <- vctrs::vec_ptype(dots$prototype_data)
tibble::as_tibble(ptype)
preds <- vec_slice(model$var_info, model$var_info$role == "predictor")
model$ptype[preds$variable]
juliasilge marked this conversation as resolved.
Show resolved Hide resolved
}

#' @rdname vetiver_create_description
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-recipe.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trained_rec <-
step_ns(wt) %>%
prep(retain = FALSE)

v <- vetiver_model(trained_rec, "car-splines", prototype_data = mtcars[c("disp", "wt")])
v <- vetiver_model(trained_rec, "car-splines")

test_that("can print recipe", {
expect_snapshot(v)
Expand Down
Loading