https://github.com/lantanacamara/lightgbmExplainer
An R package that makes lightgbm models fully interpretable (take reference from https://github.com/AppliedDataSciencePartners/xgboostExplainer)
https://github.com/lantanacamara/lightgbmExplainer
lightgbm
Last synced: about 1 month ago
JSON representation
An R package that makes lightgbm models fully interpretable (take reference from https://github.com/AppliedDataSciencePartners/xgboostExplainer)
- Host: GitHub
- URL: https://github.com/lantanacamara/lightgbmExplainer
- Owner: lantanacamara
- Created: 2017-10-09T08:16:14.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-08T05:15:42.000Z (over 6 years ago)
- Last Synced: 2025-05-30T12:18:09.656Z (10 months ago)
- Topics: lightgbm
- Language: R
- Homepage:
- Size: 25.4 KB
- Stars: 23
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-machine-learning-interpretability - lightgbmExplainer -  | "An R package that makes LightGBM models fully interpretable."| (Technical Resources / Open Source/Access Responsible AI Software Packages)
README
[](https://travis-ci.org/lantanacamara/lightgbmExplainer)
## lightgbmExplainer
An R package that makes LightGBM models fully interpretable
### Example
```
library(lightgbm) # v2.1.0 or above
library(lightgbmExplainer)
# 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")
```
Take reference from [xgboostExplainer](https://github.com/AppliedDataSciencePartners/xgboostExplainer) and credit to David Foster.
Note: LightGBM provides similar function *lgb.interprete* and *lgb.plot.interpretation*. *lgb.interprete* could be faster if you only want to interprete a few data point, but it could be much slower if you want to interprete many data point.