visually improved app.py
Browse files
app.py
CHANGED
@@ -55,14 +55,17 @@ def get_random_example():
|
|
55 |
if 'random_example' not in st.session_state:
|
56 |
st.session_state.random_example = None
|
57 |
|
58 |
-
|
|
|
|
|
|
|
59 |
st.session_state.random_example = get_random_example()
|
60 |
st.rerun()
|
61 |
|
62 |
random_example = st.session_state.random_example
|
63 |
|
64 |
-
def create_input(i):
|
65 |
-
row =
|
66 |
name = row['Name']
|
67 |
description = row['Description']
|
68 |
|
@@ -118,20 +121,30 @@ def create_input(i):
|
|
118 |
|
119 |
# create form
|
120 |
with st.form("dynamic_form"):
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
cols = st.columns(3)
|
124 |
-
with cols[0]:
|
125 |
-
for i in range(0, len(input_meta_info), 3):
|
126 |
-
create_input(i)
|
127 |
with cols[1]:
|
128 |
-
|
129 |
-
create_input(i)
|
130 |
-
with cols[2]:
|
131 |
-
for i in range(2, len(input_meta_info), 3):
|
132 |
-
create_input(i)
|
133 |
-
|
134 |
-
predict_button = st.form_submit_button("PREDICT")
|
135 |
|
136 |
# load mapping
|
137 |
with open('./data/nacc_variable_mappings.pkl', 'rb') as file:
|
|
|
55 |
if 'random_example' not in st.session_state:
|
56 |
st.session_state.random_example = None
|
57 |
|
58 |
+
cols = st.columns(3)
|
59 |
+
with cols[1]:
|
60 |
+
random_example_button = st.button("RANDOM EXAMPLE", use_container_width=True)
|
61 |
+
if random_example_button:
|
62 |
st.session_state.random_example = get_random_example()
|
63 |
st.rerun()
|
64 |
|
65 |
random_example = st.session_state.random_example
|
66 |
|
67 |
+
def create_input(df, i):
|
68 |
+
row = df.iloc[i]
|
69 |
name = row['Name']
|
70 |
description = row['Description']
|
71 |
|
|
|
121 |
|
122 |
# create form
|
123 |
with st.form("dynamic_form"):
|
124 |
+
sections = input_meta_info['Section'].unique()
|
125 |
+
for section in sections:
|
126 |
+
|
127 |
+
with st.container():
|
128 |
+
st.markdown(f"##### {section}")
|
129 |
+
sub_df = input_meta_info[input_meta_info['Section'] == section]
|
130 |
+
|
131 |
+
cols = st.columns(3)
|
132 |
+
with cols[0]:
|
133 |
+
for i in range(0, len(sub_df), 3):
|
134 |
+
create_input(sub_df, i)
|
135 |
+
with cols[1]:
|
136 |
+
for i in range(1, len(sub_df), 3):
|
137 |
+
create_input(sub_df, i)
|
138 |
+
with cols[2]:
|
139 |
+
for i in range(2, len(sub_df), 3):
|
140 |
+
create_input(sub_df, i)
|
141 |
+
|
142 |
+
# seperate line
|
143 |
+
st.markdown("---")
|
144 |
|
145 |
cols = st.columns(3)
|
|
|
|
|
|
|
146 |
with cols[1]:
|
147 |
+
predict_button = st.form_submit_button("PREDICT", use_container_width=True, type='primary')
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
# load mapping
|
150 |
with open('./data/nacc_variable_mappings.pkl', 'rb') as file:
|