# requires the Bioconductor mixOmics package
data(biomass, package = "modeldata")
biom_tr <-
biomass %>%
dplyr::filter(dataset == "Training") %>%
dplyr::select(-dataset, -sample)
biom_te <-
biomass %>%
dplyr::filter(dataset == "Testing") %>%
dplyr::select(-dataset, -sample, -HHV)
dense_pls <-
recipe(HHV ~ ., data = biom_tr) %>%
step_pls(all_numeric_predictors(), outcome = "HHV", num_comp = 3)
sparse_pls <-
recipe(HHV ~ ., data = biom_tr) %>%
step_pls(all_numeric_predictors(), outcome = "HHV", num_comp = 3,
predictor_prop = 4 / 5)
## -----------------------------------------------------------------------------
## PLS discriminant analysis
data(cells, package = "modeldata")
cell_tr <-
cells %>%
dplyr::filter(case == "Train") %>%
dplyr::select(-case)
cell_te <-
cells %>%
dplyr::filter(case == "Test") %>%
dplyr::select(-case, -class)
dense_plsda <-
recipe(class ~ ., data = cell_tr) %>%
step_pls(all_numeric_predictors(), outcome = "class", num_comp = 5)
sparse_plsda <-
recipe(class ~ ., data = cell_tr) %>%
step_pls(all_numeric_predictors(), outcome = "class", num_comp = 5,
predictor_prop = 1 / 4)
Run the code above in your browser using DataLab