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

Error in explained probability #7

Open
Dmirijs-Ozernovs opened this issue Nov 30, 2020 · 2 comments
Open

Error in explained probability #7

Dmirijs-Ozernovs opened this issue Nov 30, 2020 · 2 comments

Comments

@Dmirijs-Ozernovs
Copy link

Dmirijs-Ozernovs commented Nov 30, 2020

Hi! I found an error between predicted probability and probability derived from the explainer.
In the sample data set (agaricus) it is between -0.015 and -0.017. For other data sets error could be higher than 0.1.
Is it normal or there are ways to avoid this error?

Reproducible example:

library(lightgbm) # v2.1.0 or above
library(lightgbmExplainer)
set.seed(12345)

Load Data

data(agaricus.train, package = "lightgbm")

Train a model

lgb.dtrain <- lgb.Dataset(agaricus.train$data, label = agaricus.train$label)
lgb.params <- list(objective = "binary")
lgb.model <- lgb.train(lgb.params, lgb.dtrain, 5)

Build Explainer

lgb.trees <- lgb.model.dt.tree(lgb.model) # First get a lgb tree
explainer <- buildExplainer(lgb.trees)

compute contribution for each data point

pred.breakdown <- explainPredictions(lgb.model, explainer, agaricus.train$data)

Show waterfall for the 8th observation

showWaterfall(lgb.model, explainer, lgb.dtrain, agaricus.train$data, 8, type = "binary")

should be close to zero

predict(lgb.model,agaricus.train$data)[8] - (exp(sum(pred.breakdown[8,]))/(exp(sum(pred.breakdown[8,])) + 1))

obvious bias in errors

plot(predict(lgb.model,agaricus.train$data) - (exp(rowSums(pred.breakdown))/(exp(rowSums(pred.breakdown)) + 1)))

@alberthkcheng
Copy link
Member

Hi,
Now lightgbm has already provided lgb.plot.interpretation()

You might want to use that

@Dmirijs-Ozernovs
Copy link
Author

Hi,
Now lightgbm has already provided lgb.plot.interpretation()

You might want to use that

Thank you! Have missed it, will make my own waterfall chart from the results.

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

2 participants