library(recipes)
data(Boston, package = "MASS")
rec <- recipe(medv ~ ., data = Boston) %>%
step_pca(all_numeric_predictors(), id = "pca")
grid <- expand_steps(
pca = list(num_comp = 1:2)
)
fit(TunedInput(rec, grid = grid), model = GLMModel)
Run the code above in your browser using DataLab