mboost
mboost copied to clipboard
Variable importance doesn't work with blackboost models + possibly wrong output of `blackboost$xselect()`
I found out that varimp()
doesn't work with blackboost
models.
Code to reproduce the error:
library(mboost)
library(survival)
model <- blackboost(time ~., data=veteran)
vi <- varimp(model)
plot(vi)
I wanted to fix it, but it got complicated, see https://github.com/boost-R/mboost/blob/739cbe931693d9d81290156d431486d55d87415e/R/varimp.R#L8-L10
If learner_names
are meant to be variable names, then we could do
if (inherits(object, "blackboost")) {
learner_names <- object$baselearner[[1]]$get_names()
}
But then, object$xselect()
returns a vector of only ones, should this be the case?
model$xselect()
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[77] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
With glmboost
, everything seems to work fine?
model <- glmboost(time ~ ., data = veteran)
vi <- varimp(model)
model$xselect()
[1] 7 7 7 7 7 7 7 3 4 3 7 4 3 4 3 4 7 3 4 3 4 7 3 4 3
[26] 4 7 3 4 3 4 7 3 4 3 4 7 3 4 7 10 4 3 6 4 3 7 6 4 3
[51] 10 4 6 7 3 4 10 6 7 3 4 6 3 4 2 10 7 6 2 4 3 7 10 6 5
[76] 4 3 5 4 3 2 7 6 5 4 3 5 4 10 6 7 3 5 4 2 3 5 4 6 7
plot(vi)