Subset components
Examples
if (requireNamespace("randomPlantedForest", quietly = TRUE)) {
library(randomPlantedForest)
# introduce factor variables to show categorical feature handling
mtcars$cyl <- factor(mtcars$cyl)
mtcars$vs <- factor(mtcars$vs)
# Fit forest, get components
set.seed(12)
rpfit <- rpf(mpg ~ cyl + wt + hp + drat + vs, data = mtcars, ntrees = 25, max_interaction = 3)
components <- glex(rpfit, mtcars)
# Get component object with only "hp" and its interactions
subset_components(components, "hp")
subset_component_names(components, "hp")
}
#> [1] "hp" "cyl:hp" "hp:wt" "drat:hp" "hp:vs"
#> [6] "cyl:hp:wt" "cyl:drat:hp" "cyl:hp:vs" "drat:hp:wt" "hp:vs:wt"
#> [11] "drat:hp:vs"