eli5
eli5 copied to clipboard
Explain Prediction error
Its my first time with eli5 and i have only problems...
Thanks to one issue here i could solve the first one, but now there is another
I fitted a XGboost regression (with GPU usage) and then tried to use the explain_prediction function:
import xgboost as xgb
xgb_model = xgb.XGBRegressor(max_depth=7, learning_rate=70/100,
objective="reg:squarederror", random_state=42, n_jobs=4,
n_estimators=1500, tree_method='gpu_hist', )
xgb_model.fit(X_train, y_train)
#Changing the order of the columns so eli5 can work with it (First Error)
X_test = X_test[xgb_model._Booster.feature_names]
import eli5
df =eli5.explain_prediction_df(xgb_model,X_test)
Error:
c:\users\pascal\.conda\envs\new_env_gpu\lib\site-packages\eli5\xgboost.py in _prediction_feature_weights(booster, dmatrix, n_targets, feature_names, xgb_feature_names)
244
245 # XGBClassifier does not have pred_leaf argument, so use booster
--> 246 leaf_ids, = booster.predict(dmatrix, pred_leaf=True)
247 xgb_feature_names = {f: i for i, f in enumerate(xgb_feature_names)}
248 tree_dumps = booster.get_dump(with_stats=True)
ValueError: too many values to unpack (expected 1)
So i tried to change the row to:
leaf_ids = booster.predict(dmatrix, pred_leaf=True)
But it just run in the next error: assertion error
At this point i have no idea what went wrong.
I also have the same error.