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 66XGBoost _ is a popular Gradient Boosting library with Python interface.
77eli5 supports :func: `eli5.explain_weights ` and :func: `eli5.explain_prediction `
88for 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.
1012
1113.. _XGBoost : https://github.com/dmlc/xgboost
1214.. _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
21import re
2+ import warnings
3+ from functools import partial
34from typing import Any , Optional , Pattern , Union
45
56import numpy as np
67import scipy .sparse as sp
8+ import xgboost
79from xgboost import (
810 XGBClassifier ,
911 XGBRegressor ,
@@ -147,6 +149,11 @@ def explain_prediction_xgboost(
147149 changes from parent to child.
148150 Weights of all features sum to the output score of the estimator.
149151 """
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+
150157 booster , is_regression = _check_booster_args (xgb , is_regression )
151158 xgb_feature_names = _get_booster_feature_names (booster )
152159 vec , feature_names = handle_vec (
You can’t perform that action at this time.
0 commit comments