Graph not displayed in jupyter notebook and there is an issue: ‘TreeEnsemble’ object has no attribute ‘values’ , there is no such error in vscode
Code:
import shap
import pandas as pd
from sklearn.model_selection import train_test_split
from catboost import CatBoostClassifier
data = pd.read_csv('D:/train_for_an.csv')
X = data.drop('Survived', axis=1)
y = data['Survived']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = CatBoostClassifier(iterations=7, learning_rate=0.1, depth=3)
model.fit(X_train, y_train)
score = model.score(X_test, y_test)
shap.initjs()
explainer = shap.TreeExplainer(model, data = X)
shap_values = explainer.shap_values(X_train)
I was expecting to see a graph and in vscode errors: ‘TreeEnsemble’ object has no attribute ‘values’ is not present
Always provide the full error traceback. What version of shap do you have, and are you sure it’s the same between vscode and jupyter?