Closed
Description
From some digging. prepare_data()
doesn't remove outcomes y
if model was fit with fit_xy()
. This because an issue here because {xgboost} doesn't like that, while other models doesn't care.
library(parsnip)
spec <- boost_tree() %>%
set_mode("regression") %>%
set_engine("xgboost")
lm_fit <- fit(spec, mpg ~ ., data = mtcars)
predict(lm_fit, mtcars)
#> # A tibble: 32 × 1
#> .pred
#> <dbl>
#> 1 20.9
#> 2 20.9
#> 3 22.6
#> 4 21.0
#> 5 18.4
#> 6 18.1
#> 7 14.2
#> 8 23.7
#> 9 22.4
#> 10 18.9
#> # ℹ 22 more rows
lm_fit <- fit_xy(spec, x = mtcars[, -1], y = mtcars[, 1])
predict(lm_fit, mtcars)
#> Error in predict.xgb.Booster(object, new_data, ...): Feature names stored in `object` and `newdata` are different!
Created on 2024-08-30 with reprex v2.1.0