Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# --- Configure the app ---
|
| 4 |
+
st.set_page_config(page_title="Multiplicity Demo", layout="centered")
|
| 5 |
+
|
| 6 |
+
# --- Initialize session state ---
|
| 7 |
+
if "page" not in st.session_state:
|
| 8 |
+
st.session_state.page = "landing" # can be: landing, main, sentence_X
|
| 9 |
+
|
| 10 |
+
# --- Helper function to change page ---
|
| 11 |
+
def go_to(page_name):
|
| 12 |
+
st.session_state.page = page_name
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# -----------------------------
|
| 16 |
+
# Landing Page
|
| 17 |
+
# -----------------------------
|
| 18 |
+
if st.session_state.page == "landing":
|
| 19 |
+
st.markdown(
|
| 20 |
+
"""
|
| 21 |
+
<div style='text-align: center; font-size:14px; color:gray;'>
|
| 22 |
+
Welcome to the Multiplicity Interactive Demo.<br><br>
|
| 23 |
+
In this demo, you will explore how developer decisions create a multiverse of possible models,
|
| 24 |
+
and how these connect to concepts like arbitrariness, homogenization, and the ICA framework.<br><br>
|
| 25 |
+
Follow the steps to see your decisions in context.
|
| 26 |
+
</div>
|
| 27 |
+
""",
|
| 28 |
+
unsafe_allow_html=True
|
| 29 |
+
)
|
| 30 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 31 |
+
if st.button("Get Started"):
|
| 32 |
+
go_to("main")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# -----------------------------
|
| 36 |
+
# Main Page (Clickable Sentences)
|
| 37 |
+
# -----------------------------
|
| 38 |
+
elif st.session_state.page == "main":
|
| 39 |
+
st.markdown(
|
| 40 |
+
"<div style='font-size:24px; color:#3366cc; font-weight:bold;'>Explore the concepts:</div>",
|
| 41 |
+
unsafe_allow_html=True
|
| 42 |
+
)
|
| 43 |
+
st.write("") # spacing
|
| 44 |
+
|
| 45 |
+
sentences = [
|
| 46 |
+
"Multiplicity: Many models, same accuracy, different predictions.",
|
| 47 |
+
"ICA Framework: Intentional, Conventional, and Arbitrary decisions.",
|
| 48 |
+
"Arbitrariness: Why different models might treat individuals differently.",
|
| 49 |
+
"Homogenization: Why similar decisions happen across many developers."
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
for i, sentence in enumerate(sentences):
|
| 53 |
+
if st.button(sentence, key=f"sentence_{i}"):
|
| 54 |
+
go_to(f"sentence_{i}")
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
# -----------------------------
|
| 58 |
+
# Empty Sentence Pages
|
| 59 |
+
# -----------------------------
|
| 60 |
+
else:
|
| 61 |
+
# Extract sentence index
|
| 62 |
+
sentence_index = int(st.session_state.page.split("_")[1])
|
| 63 |
+
|
| 64 |
+
st.markdown(
|
| 65 |
+
f"<div style='font-size:20px; color:#cc3333; font-weight:bold;'>Page for Sentence {sentence_index + 1}</div>",
|
| 66 |
+
unsafe_allow_html=True
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
st.write("This page is currently empty. You can add the content for this concept here.")
|
| 70 |
+
|
| 71 |
+
if st.button("Back to Main Page"):
|
| 72 |
+
go_to("main")
|