Closed gerileka closed 4 years ago
@gerileka My guess is the base learner you used isn't compatible. Can you share what that learner is?
@ryan-wolbeck hi, thank you for your interests. I used the stock version from the user guide website, without change.
from ngboost import NGBRegressor
from sklearn.datasets import load_boston from sklearn.model_selection import train_test_split from sklearn.metrics import mean_squared_error
X, Y = load_boston(True) X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2)
ngb = NGBRegressor().fit(X_train, Y_train) Y_preds = ngb.predict(X_test) Y_dists = ngb.pred_dist(X_test)
feature_importance_loc = ngb.featureimportances[0]
feature_importance_scale = ngb.featureimportances[1]
import shap shap.initjs() explainer = shap.TreeExplainer(ngb, model_output=0)
I spun up a colab notebook and was able to run it without error:
@ryan-wolbeck Thank you. I tried as well and I think that is my version of shap. Installed it like last year, maybe I need an update on the library.
""" Trying the new library for probabilistic regression and classifcation. Minor problems when using the Shap explainer
"""
SHAP plot for loc tree
import shap shap.initjs() explainer = shap.TreeExplainer(ngb, X, model_output=0) shap_values = explainer.shap_values(X) shap.dependence_plot(0, shap_values, X)
Gives the following Error
Exception Traceback (most recent call last)