<jupyter_start><jupyter_text>Summarize the effects of all the features<jupyter_code>new_size = 60
chanel = 1
fig = shap.summary_plot(np.sum(shap_values, axis=chanel), 
                  features=np.sum(features[:500,:,:].cpu().numpy(), axis=chanel),
                  feature_names=None, plot_type='violin')
plt.savefig('shap_features_summary.png')
subject = 4
shap_values[subject, :].shape, features[subject, :, :].cpu().numpy().shape
features[subject:subject+1,:,:].shape
subject = 20

shap_values = explainer.shap_values(features[subject:subject+1,:,:], ranked_outputs=True)


new_size = 60
chanel = 1

# Init the JS visualization code
shap.initjs()
# Choosing which example to use

# Plot the explanation of the predictions for one subject
shap.force_plot(explainer.expected_value[0], 
                shap_values[subject, :, :].T, 
                features=features[subject, :, :].T.cpu().numpy(), 
                feature_names=None)<jupyter_output><empty_output><jupyter_text>Get the ordered impotant features<jupyter_code>shap_values[subject, :, :].shape<jupyter_output><empty_output><jupyter_text>Important days for single account<jupyter_code>vals= np.sum(np.abs(shap_values[subject, :, :]), axis=0)
feature_importance = pd.DataFrame(list(zip(range(0, 60),vals)),columns=['col_name','feature_importance_vals'])
feature_importance.sort_values(by=['feature_importance_vals'],ascending=False,inplace=True)
feature_importance.head()
vals= np.abs(shap_values[subject, :, :]).mean(0)
feature_importance = pd.DataFrame(list(zip(range(0, 60),vals)),columns=['col_name','feature_importance_vals'])
feature_importance.sort_values(by=['feature_importance_vals'],ascending=False,inplace=True)
feature_importance.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14833906071019473, 'fraction_numerical': 0.013172966781214204, 'mean_word_length': 6.662280701754386, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '577265', 'license': 'Apache-2.0', 'n_tokens_mistral': 625, 'n_tokens_neox': 596, 'n_words': 84, 'path': 'shap.ipynb', 'repo_name': 'sepidehhosseinzadeh/shapley-values-deep-explainer', 'size': '1746'}