plot_effects {sgboost} | R Documentation |
Visualizing a sparse-group boosting model
Description
Radar or scatter/lineplot visualizing the effects sizes relative to the variable importance in a sparse-group boosting model. Works also for a regular mboost model.
Usage
plot_effects(
sgb_model,
plot_type = "radar",
prop = 0,
n_predictors = 30,
max_char_length = 5,
base_size = 8
)
Arguments
sgb_model |
Model of type |
plot_type |
String indicating the type of visualization to use.
|
prop |
Numeric value indicating the minimal importance a predictor/baselearner has to have to be plotted.
Default value is zero, meaning all predictors are plotted. By increasing prop the number of
plotted variables can be reduced. One can also use |
n_predictors |
The maximum number of predictors to be plotted. Default is 30.
Alternative to |
max_char_length |
The maximum character length of a predictor to be printed. Default is 5. For long variable names one may adjust this number. |
base_size |
The |
Value
ggplot2
object mapping the effect sizes and variable importance.
See Also
get_coef()
, get_varimp()
which this function uses.
Examples
library(mboost)
library(dplyr)
set.seed(1)
df <- data.frame(
x1 = rnorm(100), x2 = rnorm(100), x3 = rnorm(100),
x4 = rnorm(100), x5 = runif(100)
)
df <- df %>%
mutate_all(function(x) {
as.numeric(scale(x))
})
df$y <- df$x1 + df$x4 + df$x5
group_df <- data.frame(
group_name = c(1, 1, 1, 2, 2),
var_name = c("x1", "x2", "x3", "x4", "x5")
)
sgb_formula <- as.formula(create_formula(alpha = 0.3, group_df = group_df))
sgb_model <- mboost(formula = sgb_formula, data = df)
plot_effects(sgb_model)