Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hbaniecki opened this issue Dec 17, 2022 · 0 comments

Comments

@hbaniecki
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant