View source: R/plot_ind_contr.R
plotIndividualContribution | R Documentation |
This function visualizes the contribution of each feature regarding the predicted value.
By default, multiple base learners defined on one feature are aggregated. If you
want to show the contribution of single base learner, then set aggregate = FALSE
.
plotIndividualContribution(
cboost,
newdata,
aggregate = TRUE,
colbreaks = c(-Inf, 0, Inf),
collabels = c("negative", "positive"),
nround = 2L,
offset = TRUE
)
cboost |
(Compboost) |
newdata |
( |
aggregate |
( |
colbreaks |
( |
collabels |
( |
nround |
( |
offset |
( |
ggplot
object containing the graphic.
dat = mtcars
fnum = c("cyl", "disp", "hp", "drat", "wt", "qsec")
fcat = c("vs", "am", "gear", "carb")
for (fn in fcat) dat[[fn]] = as.factor(dat[[fn]])
cboost = Compboost$new(data = dat, target = "mpg",
loss = LossQuadratic$new())
for (fn in fnum) cboost$addComponents(fn, df = 3)
for (fn in fcat) cboost$addBaselearner(fn, "ridge", BaselearnerCategoricalRidge)
cboost$train(500L)
cbreaks = c(-Inf, -0.1, 0.1, Inf)
clabs = c("bad", "middle", "good")
plotIndividualContribution(cboost, dat[10, ], colbreaks = cbreaks,
collabels = clabs)
plotIndividualContribution(cboost, dat[10, ], offset = FALSE,
colbreaks = cbreaks, collabels = clabs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.