Skip to content

Variable importance doesn't work with blackboost models + possibly wrong output of blackboost$xselect() #119

Description

@hbaniecki

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)

image

I wanted to fix it, but it got complicated, see

mboost/R/varimp.R

Lines 8 to 10 in 739cbe9

learner_names <- if( !(inherits(object, "glmboost")) )
names(object$baselearner) else variable.names(object)
learner_selected <- object$xselect()

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)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions