Skip to content

Error: Should unify use the target variable? #14

New issue

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

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

Already on GitHub? # to your account

Closed
hbaniecki opened this issue Jun 1, 2021 · 0 comments · Fixed by #30
Closed

Error: Should unify use the target variable? #14

hbaniecki opened this issue Jun 1, 2021 · 0 comments · Fixed by #30

Comments

@hbaniecki
Copy link
Member

hbaniecki commented Jun 1, 2021

This code returns an error:

n <- 1000
p <- 5
X <- as.data.frame(matrix(rnorm(n*p), nrow=n))
logit <- exp(X[, 1] * X[, 2])
y <- 1 / (1 + logit) > 0.5
plot(X[, 1], X[, 2], col = as.factor(y))
plot(X[, 1], X[, 3], col = as.factor(y))
df <- cbind(X, y = y)
            
library(gbm)
model <- gbm(y~., data=df, interaction.depth=2, n.trees=50)

library(treeshap)
uexp <- gbm.unify(model, X)
treeshap1 <- treeshap(uexp,  X, verbose = 0)
plot_feature_importance(treeshap1)

plot_contribution(treeshap1)

When passing df to gbm.unify and treeshap, the y variable shows on both plots, and it should not.

@krzyzinskim krzyzinskim mentioned this issue Sep 27, 2023
@krzyzinskim krzyzinskim linked a pull request Sep 27, 2023 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant