diff --git a/DESCRIPTION b/DESCRIPTION index 4b97248d..fc51bb3e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,7 +24,7 @@ Imports: hardhat (>= 1.2.0), lifecycle (>= 1.0.3), modelenv (>= 0.1.0), - parsnip (>= 1.1.0.9001), + parsnip (>= 1.1.1.9004), rlang (>= 1.0.3), tidyselect (>= 1.2.0), vctrs (>= 0.4.1) diff --git a/tests/testthat/_snaps/pre-action-recipe.md b/tests/testthat/_snaps/pre-action-recipe.md index d79d22c5..df2155dc 100644 --- a/tests/testthat/_snaps/pre-action-recipe.md +++ b/tests/testthat/_snaps/pre-action-recipe.md @@ -22,7 +22,7 @@ Error in `add_recipe()`: ! A recipe cannot be added when variables already exist. -# cannot add a recipe if recipes is trained +# cannot add a recipe if recipe is trained Code add_recipe(workflow, rec) diff --git a/tests/testthat/test-predict.R b/tests/testthat/test-predict.R index 2c84bac0..c2160405 100644 --- a/tests/testthat/test-predict.R +++ b/tests/testthat/test-predict.R @@ -134,20 +134,21 @@ test_that("blueprint will get passed on to hardhat::forge()", { ) }) -test_that("monitoring: known that parsnip removes blueprint intercept for some models (tidymodels/parsnip#353)", { +test_that("monitoring: no double intercept due to dot expansion in model formula #210", { mod <- parsnip::linear_reg() mod <- parsnip::set_engine(mod, "lm") - # Pass formula explicitly to keep `lm()` from auto-generating an intercept + # model formula includes a dot to mean "everything available after the preprocessing formula workflow <- workflow() - workflow <- add_model(workflow, mod, formula = mpg ~ . + 0) + workflow <- add_model(workflow, mod, formula = mpg ~ .) blueprint_with_intercept <- hardhat::default_formula_blueprint(intercept = TRUE) workflow_with_intercept <- add_formula(workflow, mpg ~ hp + disp, blueprint = blueprint_with_intercept) fit_with_intercept <- fit(workflow_with_intercept, mtcars) - # `parsnip:::prepare_data()` will remove the intercept, so it won't be - # there when the `lm()` `predict()` method is called. We don't own this - # error though. - expect_error(predict(fit_with_intercept, mtcars)) + # The dot expansion used to include the intercept column, added via the blueprint, as a regular predictor. + # `parsnip:::prepare_data()` removed this column, so lm's predict method errored. + # Now it gets removed before fitting (lm will handle the intercept itself), + # so lm()'s predict method won't error anymore here. (tidymodels/parsnip#1033) + expect_no_error(predict(fit_with_intercept, mtcars)) })