Conversation
mainly followed the logic of xgboost.booster support
add lightgbm.booster support
Codecov Report
@@ Coverage Diff @@
## master #270 +/- ##
==========================================
- Coverage 97.22% 97.22% -0.01%
==========================================
Files 44 44
Lines 2815 2845 +30
Branches 536 545 +9
==========================================
+ Hits 2737 2766 +29
Misses 41 41
- Partials 37 38 +1
|
eli5/lightgbm.py
Outdated
|
|
||
|
|
||
| def _check_booster_args(lgb, is_regression=None): | ||
| # type: (Any, bool) -> Tuple[Booster, bool] |
There was a problem hiding this comment.
I hope something like # type: (Any, bool) -> Tuple[lightgbm.Booster, bool] and adding Tuple and Any to typing imports at the top should fix the build (https://travis-ci.org/TeamHG-Memex/eli5/jobs/385021206#L764-L766). To check locally, you can try installing mypy==0.550 and running mypy --check-untyped-defs eli5
|
Thanks for the PR @qh582 , at first sight it looks good 👍 |
|
@lopuhin Thanks for review and suggestion. solved it. I am doing the |
add explain_prediction test for regression booster
fix bug of using multiclass booster to fit binary case
|
@lopuhin could you please check it? |
adding test done
|
@qh582 looks good! Would you mind updating a few notes in docs, mentioning this new feature? |
* Update overview.rst * Update README.rst * Update lightgbm.rst
* Update overview.rst * Update README.rst * Update lightgbm.rst
|
@kmike I think this is ready, please check :) |
| ("objective" starts with "reg") | ||
| and False for a classification problem. | ||
| If not set, regression is assumed for a single target estimator | ||
| and proba will not be shown unless the ``target_names`` is defined as a list with length of two. |
There was a problem hiding this comment.
This seems to contradict a note above (line 25, "target_names is ignored") - does the note about target_names apply only to classifier/regressor, but not for Booster?
There was a problem hiding this comment.
for a single target estimater, booster cannot recognize wheather it is a regression problem or not. We assume it is regression in default, unless users set it as a classification problem by assigning 'target names' input [0,1] etc. Only in this case 'target names' is used. Should I remove " target names is ignored" to prevent confusion?
There was a problem hiding this comment.
target names is still ignored for classifier/regressor, right? I think it makes sense to clarify it - just say that it is ignored for LGBMClassifier / LGBMRegressor, but used for lightgbm.Booster.
"is defined as a list with length of two" - sohuld it be 2 elements, or 2+ is also supported?
There was a problem hiding this comment.
Well, for single target booster, only 1+ elements target_name point booster to classification. Otherwise, this booster is regression . there is risk user assign wrong number of elements like 3, but not sure how eli5 will raise error. 2+ should not support here.
docs/source/libraries/lightgbm.rst
Outdated
| and :func:`eli5.explain_prediction` for ``lightgbm.LGBMClassifer`` | ||
| and ``lightgbm.LGBMRegressor`` estimators. | ||
| and :func:`eli5.explain_prediction` for ``lightgbm.LGBMClassifer``, ``lightgbm.LGBMRegressor`` and ``lightgbm.Booster`` estimators. It is tested against LightGBM | ||
| master branch. |
There was a problem hiding this comment.
"It is tested against LightGBM master branch." is removed in 63e9918, sorry for the confusion. It shouldn't be re-added.
There was a problem hiding this comment.
got it, I will remove that line in next commit
|
@kmike Hope the new commit help. My previous piece of code is not strict enough. |
|
It's been two month, could someone tell me why this merge hasn't been closed already? I really need this. |
|
I think PR is in great shape and we just need to check it again and merge it, hope to find time for it soonish, sorry for delay. |
|
|
||
| :func:`eli5.explain_weights` uses feature importances. Additional | ||
| arguments for LGBMClassifier and LGBMClassifier: | ||
| arguments for LGBMClassifier , LGBMClassifier and lightgbm.Booster: |
There was a problem hiding this comment.
a nitpick: extra whitespace before comma
| :ref:`library-xgboost`. | ||
|
|
||
| ``target_names`` and ``target`` arguments are ignored. | ||
| ``target_names`` arguement is ignored for ``lightgbm.LGBMClassifer`` / ``lightgbm.LGBMRegressor``, but used for ``lightgbm.Booster``. ``target`` argument is ignored. |
There was a problem hiding this comment.
| ``target_names`` arguement is ignored for ``lightgbm.LGBMClassifer`` / ``lightgbm.LGBMRegressor``, but used for ``lightgbm.Booster``. ``target`` argument is ignored. | |
| ``target_names`` argument is ignored for ``lightgbm.LGBMClassifer`` / ``lightgbm.LGBMRegressor``, but used for ``lightgbm.Booster``. ``targets`` argument is ignored. |
|
|
||
| :func:`eli5.explain_weights` uses feature importances. Additional | ||
| arguments for LGBMClassifier and LGBMClassifier: | ||
| arguments for LGBMClassifier , LGBMClassifier and lightgbm.Booster: |
There was a problem hiding this comment.
| arguments for LGBMClassifier , LGBMClassifier and lightgbm.Booster: | |
| arguments for LGBMClassifier, LGBMClassifier and lightgbm.Booster: |
| ``target_names`` arguement is ignored for ``lightgbm.LGBMClassifer`` / ``lightgbm.LGBMRegressor``, but used for ``lightgbm.Booster``. ``target`` argument is ignored. | ||
|
|
||
| .. note:: | ||
| Top-level :func:`eli5.explain_weights` calls are dispatched |
There was a problem hiding this comment.
I think lightgbm.Booster should be mentioned here as well.
|
|
||
| ``lightgbm.Booster`` estimator accepts one more optional argument: | ||
|
|
||
| * ``is_regression`` - True if solving a regression problem |
There was a problem hiding this comment.
Is this parameter supported? It is not an argument of explain_prediction_lightgbm.
|
|
||
| * :ref:`library-lightgbm` - show feature importances and explain predictions | ||
| of LGBMClassifier and LGBMRegressor. | ||
| of LGBMClassifier , LGBMRegressor and lightgbm.Booster. |
There was a problem hiding this comment.
| of LGBMClassifier , LGBMRegressor and lightgbm.Booster. | |
| of LGBMClassifier, LGBMRegressor and lightgbm.Booster. |
| ``target_names`` and ``targets`` parameters are ignored. | ||
| ``target_names`` arguement is ignored for ``lightgbm.LGBMClassifer`` / ``lightgbm.LGBMRegressor``, | ||
| but used for ``lightgbm.Booster``. | ||
| ``target`` argument is ignored. |
There was a problem hiding this comment.
| ``target`` argument is ignored. | |
| ``targets`` argument is ignored. |
|
Any plans about merging it, @lopuhin? |
|
Thanks you! This were merged in eli5-org/eli5#7 and released to PyPI with v0.11 |

mainly followed the logic of xgboost.booster support