Skip to content

boston-house-ml-app.py - PyplotGlobalUseWarning: You are calling st.pyplot() without any arguments. #14

Description

@datalifenyc

When plotting the 2 SHAP figures, the figures appear, but the following warning also appears.

st.header('Feature Importance')
plt.title('Feature importance based on SHAP values')
shap.summary_plot(shap_values, X)
st.pyplot(bbox_inches = 'tight')
st.write('----')

plt.title('Feature importance based on SHAP values (Bar)')
shap.summary_plot(shap_values, X, plot_type = 'bar')
st.pyplot(bbox_inches = 'tight')

PyplotGlobalUseWarning: You are calling st.pyplot() without any arguments. After December 1st, 2020, we will remove the ability to do this as it requires the use of Matplotlib's global figure object, which is not thread-safe.

The temporary solution is to configure the streamlit option:

st.set_option('deprecation.showPyplotGlobalUse', False)

However, is there a solution that does not require disabling deprecation warnings?

For some of the prior examples, like the basketball_app.py, it was easy to determine what to pass as the fig:

st.pyplot(f)

For this streamlit dashboard, which incorporates the SHAP library, what can be passed in as the <fig> in line 81 & 86: st.pyplot(<fig?>, bbox_inches = 'tight')?

Version Reference:
python - 3.10.0
matplotlib - 3.5.1
streamlit - 1.5.1
scikit-learn - 1.0.2
shap - 0.39.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions