File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 6
6
XGBoost _ is a popular Gradient Boosting library with Python interface.
7
7
eli5 supports :func: `eli5.explain_weights ` and :func: `eli5.explain_prediction `
8
8
for XGBClassifer _, XGBRegressor _ and Booster _ estimators. It is tested for
9
- xgboost >= 0.6a2.
9
+ xgboost >= 0.6a2 and < 2.0.0.
10
+ Versions starting from 2.0.0 likely produce incorrect results in
11
+ :func: `eli5.explain_prediction `, and will issue a warning.
10
12
11
13
.. _XGBoost : https://github.com/dmlc/xgboost
12
14
.. _XGBClassifer : https://xgboost.readthedocs.io/en/latest/python/python_api.html#xgboost.XGBClassifier
Original file line number Diff line number Diff line change 1
- from functools import partial
2
1
import re
2
+ import warnings
3
+ from functools import partial
3
4
from typing import Any , Optional , Pattern , Union
4
5
5
6
import numpy as np
6
7
import scipy .sparse as sp
8
+ import xgboost
7
9
from xgboost import (
8
10
XGBClassifier ,
9
11
XGBRegressor ,
@@ -147,6 +149,11 @@ def explain_prediction_xgboost(
147
149
changes from parent to child.
148
150
Weights of all features sum to the output score of the estimator.
149
151
"""
152
+ if not xgboost .__version__ .startswith (('0.' , '1.' )):
153
+ warnings .warn (
154
+ 'This explanation might be incoorrect, '
155
+ 'only xgboost < 2.0.0 is known to work correctly' )
156
+
150
157
booster , is_regression = _check_booster_args (xgb , is_regression )
151
158
xgb_feature_names = _get_booster_feature_names (booster )
152
159
vec , feature_names = handle_vec (
You can’t perform that action at this time.
0 commit comments