knime interactive view with shap force plot

Hello.
I’m working on Python based KNIME Extension - type “knext.NodeType.VISUALIZER”.
I got an error when i tried to view shap.force_plot :


while in jupyter notebook i got the result:

the line i used from shap:

shap_html=shap.force_plot(explainer.expected_value, 
 shap_values_list,feature_names=list(df_panel.columns), show=False)

and i do have shap.initjs() in the “execute” function that in the extension file

any solution?

Thanks in advance,
Hagay

Hi @hagay_finiti,
The Python view is not the same as a notebook. The view must be a self-contained HTML file. I am not familiar with the library but it seems to make use of some additional JS code that is not available in the HTML that you output to knext.view. The shap.initjs() probably injects that into the current DOM in the notebook (or something similar).
Maybe there is a method to export the view as a self-contained HTML. Otherwise, you have to add the JavaScript library to the HTML manually.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.