I have a tensorflow model with 2 target vars that i would like to view its SHAP values as following:
import pandas as pd
import tensorflow as tf
import shap
x_df = pd.DataFrame({'var1':[4, 6, 19, 8],
'var2':[7, 21, 5, 12],
'var3':[11, 15, 19, 5],
'var4':[8, 1, 16, 18]})
target_var = pd.DataFrame({'y1': [12, 4, 6, 8],
'y2': [11, 13, 9, 12]})
model = tf.keras.models.Sequential([
tf.keras.layers.Dense(4, activation='sigmoid'),
tf.keras.layers.Dense(2)])
model.compile(optimizer='adam', loss="mse")
model.fit(x_df.values, target_var, epochs=1, batch_size=2)
explainer = shap.DeepExplainer(model, x_df)
shap_values = explainer.shap_values(x_df)
shap.summary_plot(shap_values, x_df)
Im using several tutorials that explain that i can insert the tf model straight into the explainer and use it, however the .shap values returns an error as following:
AttributeError: 'tuple' object has no attribute 'rank'