Spaces:
Sleeping
Sleeping
File size: 2,049 Bytes
5ead791 5e91161 5ead791 f6eb5e3 5ead791 b30bcef 5ead791 f6eb5e3 5ead791 f6eb5e3 5ead791 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import pandas as pd
import plotly.express as px
import streamlit as st
def _viz_wealth(results):
wealth = results["wealth"]
concepts = results["concepts"]
significance_level = results["significance_level"]
wealth_mu = wealth.mean(axis=0)
wealth_df = []
for concept_idx, concept in enumerate(concepts):
for t in range(wealth.shape[1]):
wealth_df.append(
{"time": t, "concept": concept, "wealth": wealth_mu[t, concept_idx]}
)
wealth_df = pd.DataFrame(wealth_df)
fig = px.line(wealth_df, x="time", y="wealth", color="concept")
fig.add_hline(
y=1 / significance_level,
line_dash="dash",
line_color="black",
annotation_text="Rejection threshold (1 / α)",
annotation_position="bottom right",
)
fig.update_yaxes(range=[0, 1.5 * 1 / significance_level])
st.plotly_chart(fig, use_container_width=True)
def viz_results():
results = st.session_state.results
if results is None:
st.info("Test concepts to show results", icon="ℹ️")
else:
rank_tab, wealth_tab = st.tabs(["Rank of importance", "Wealth process"])
with rank_tab:
st.subheader("Rank of Semantic Importance")
with st.expander("Details"):
st.write(
"This tab shows the rank of semantic importance of the concepts for the predictions of the model on the image. Concepts are sorted by increasing rejection time, where a shorter rejection time indicates higher importance."
)
with wealth_tab:
st.subheader("Wealth Process of Testing Procedures")
with st.expander("Details"):
st.write(
"This tab shows the average wealth process of the testing procedures for random draws of conditioning subsets with the same cardinality. The black dashed line represents the rejection threshold."
)
if results is not None:
_viz_wealth(results)
|