Update my_pages/multiverse.py
Browse files- my_pages/multiverse.py +47 -3
my_pages/multiverse.py
CHANGED
|
@@ -3,6 +3,34 @@ import streamlit as st
|
|
| 3 |
import plotly.graph_objects as go
|
| 4 |
from utils import go_to
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def build_tree_and_trace_path(selected_path):
|
| 7 |
"""
|
| 8 |
Build tree nodes and edges. Then trace selected_path (one choice per stage)
|
|
@@ -18,7 +46,7 @@ def build_tree_and_trace_path(selected_path):
|
|
| 18 |
y_spacing_base = 1.0
|
| 19 |
|
| 20 |
# Build nodes and edges stage by stage
|
| 21 |
-
for stage_idx, stage in enumerate(
|
| 22 |
options = stage["questions"]
|
| 23 |
next_nodes = []
|
| 24 |
|
|
@@ -67,11 +95,21 @@ def build_tree_and_trace_path(selected_path):
|
|
| 67 |
|
| 68 |
|
| 69 |
def render():
|
| 70 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
# --- User picks one choice per stage via dropdowns ---
|
| 73 |
selected_path = []
|
| 74 |
-
for stage in
|
| 75 |
# use a stable key per stage to avoid conflicts
|
| 76 |
key = f"multiverse_choice_{stage['label']}"
|
| 77 |
choice = st.selectbox(f"{stage['icon']} {stage['label']}", stage["questions"], key=key)
|
|
@@ -130,3 +168,9 @@ def render():
|
|
| 130 |
)
|
| 131 |
|
| 132 |
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import plotly.graph_objects as go
|
| 4 |
from utils import go_to
|
| 5 |
|
| 6 |
+
choices_list = [
|
| 7 |
+
{"label": "Data Collection", "icon": "📥", "questions": [
|
| 8 |
+
"Where will you source the data from?",
|
| 9 |
+
"How will you ensure data quality?",
|
| 10 |
+
"Will you balance classes?"
|
| 11 |
+
]},
|
| 12 |
+
{"label": "Preprocessing", "icon": "🛠️", "questions": [
|
| 13 |
+
"What features will you select?",
|
| 14 |
+
"Will you impute missing values or remove them?",
|
| 15 |
+
"How will you handle outliers?"
|
| 16 |
+
]},
|
| 17 |
+
{"label": "Model Selection", "icon": "🤖", "questions": [
|
| 18 |
+
"Which algorithms will you consider?",
|
| 19 |
+
"Will you use pre-trained models?",
|
| 20 |
+
"How will you handle hyperparameters?"
|
| 21 |
+
]},
|
| 22 |
+
{"label": "Training", "icon": "🏋️", "questions": [
|
| 23 |
+
"What loss function will you use?",
|
| 24 |
+
"How will you split train/validation?",
|
| 25 |
+
"Will you use early stopping?"
|
| 26 |
+
]},
|
| 27 |
+
{"label": "Evaluation", "icon": "📊", "questions": [
|
| 28 |
+
"What metrics will you use?",
|
| 29 |
+
"Will you test on unseen data?",
|
| 30 |
+
"Will you consider fairness metrics?"
|
| 31 |
+
]}
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
def build_tree_and_trace_path(selected_path):
|
| 35 |
"""
|
| 36 |
Build tree nodes and edges. Then trace selected_path (one choice per stage)
|
|
|
|
| 46 |
y_spacing_base = 1.0
|
| 47 |
|
| 48 |
# Build nodes and edges stage by stage
|
| 49 |
+
for stage_idx, stage in enumerate(choices_list, start=1):
|
| 50 |
options = stage["questions"]
|
| 51 |
next_nodes = []
|
| 52 |
|
|
|
|
| 95 |
|
| 96 |
|
| 97 |
def render():
|
| 98 |
+
st.markdown(
|
| 99 |
+
"""
|
| 100 |
+
<div style='text-align: center; font-size:18px; color:gray;'>
|
| 101 |
+
Consider data about individuals who either paid their loans (green) or defaulted (red). <br>
|
| 102 |
+
Which model out of the two will you choose to give loan applications? <br>
|
| 103 |
+
</div>
|
| 104 |
+
""",
|
| 105 |
+
unsafe_allow_html=True
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
st.markdown("---")
|
| 109 |
|
| 110 |
# --- User picks one choice per stage via dropdowns ---
|
| 111 |
selected_path = []
|
| 112 |
+
for stage in choices_list:
|
| 113 |
# use a stable key per stage to avoid conflicts
|
| 114 |
key = f"multiverse_choice_{stage['label']}"
|
| 115 |
choice = st.selectbox(f"{stage['icon']} {stage['label']}", stage["questions"], key=key)
|
|
|
|
| 168 |
)
|
| 169 |
|
| 170 |
st.plotly_chart(fig, use_container_width=True)
|
| 171 |
+
|
| 172 |
+
st.markdown("---")
|
| 173 |
+
col1, col2, col3, col4 = st.columns([2, 1, 1, 1])
|
| 174 |
+
with col3:
|
| 175 |
+
if st.button("Go Home"):
|
| 176 |
+
go_to("home")
|