# NOT RUN {
library(modeldata)
data(biomass)
biomass_tr <- biomass[biomass$dataset == "Training",]
biomass_te <- biomass[biomass$dataset == "Testing",]
rec <- recipe(HHV ~ carbon + hydrogen + oxygen + nitrogen + sulfur,
data = biomass_tr)
kpca_trans <- rec %>%
step_YeoJohnson(all_numeric_predictors()) %>%
step_normalize(all_numeric_predictors()) %>%
step_kpca_poly(all_numeric_predictors())
if (require(ggplot2) & require(kernlab)) {
kpca_estimates <- prep(kpca_trans, training = biomass_tr)
kpca_te <- bake(kpca_estimates, biomass_te)
ggplot(kpca_te, aes(x = kPC1, y = kPC2)) +
geom_point() +
coord_equal()
tidy(kpca_trans, number = 3)
tidy(kpca_estimates, number = 3)
}
# }
Run the code above in your browser using DataLab