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

add lightgbm.booster support #270

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eli5/lightgbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def get_score_weights(_label_id):
target_names=target_names,
targets=targets,
top_targets=top_targets,
is_regression=isinstance(lgb, lightgbm.LGBMRegressor),
is_regression=is_regression,
is_multiclass=n_targets > 1,
proba=proba,
get_score_weights=get_score_weights,
Expand Down
11 changes: 11 additions & 0 deletions tests/test_lightgbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
)
from .test_sklearn_explain_prediction import (
assert_linear_regression_explained,
assert_trained_linear_regression_explained,
test_explain_prediction_pandas as _check_explain_prediction_pandas,
test_explain_clf_binary_iris as _check_binary_classifier,
)
Expand Down Expand Up @@ -193,3 +194,13 @@ def test_explain_lightgbm_booster(boston_train):
res = explain_weights(booster, feature_names=feature_names)
for expl in format_as_all(res, booster):
assert 'LSTAT' in expl

def test_explain_prediction_reg_booster(boston_train):
X, y, feature_names = boston_train
booster = lightgbm.train(
params={'objective': 'regression', 'verbose_eval': -1},
train_set=lightgbm.Dataset(X, label=y),
)
assert_trained_linear_regression_explained(
X[0], feature_names, booster, explain_prediction,
reg_has_intercept=True)