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

Fixing incorrect model parse when XGB buf starts with 'binff' or 'binfn' #2162

Merged
merged 8 commits into from Jun 15, 2022
5 changes: 4 additions & 1 deletion shap/explainers/_tree.py
Expand Up @@ -1414,7 +1414,10 @@ class XGBTreeModelLoader(object):
"""
def __init__(self, xgb_model):
# new in XGBoost 1.1, 'binf' is appended to the buffer
self.buf = xgb_model.save_raw().lstrip(b'binf')
self.buf = xgb_model.save_raw()
start_buf = self.buf[:4]
if start_buf == bytearray(b'binf'):
self.buf = self.buf[4:]
self.pos = 0

# load the model parameters
Expand Down