Spaces:
Runtime error
Runtime error
Isabel Gwara
commited on
Commit
·
e2e4921
1
Parent(s):
9ce0485
Update app.py
Browse files
app.py
CHANGED
@@ -14,13 +14,11 @@ from sklearn import metrics
|
|
14 |
### interface setup ###
|
15 |
### ----------------------------- ###
|
16 |
|
17 |
-
col1, col2 = st.columns(2)
|
18 |
-
|
19 |
with open('styles.css') as f:
|
20 |
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
21 |
|
22 |
-
|
23 |
-
|
24 |
|
25 |
|
26 |
### ------------------------------ ###
|
@@ -92,23 +90,6 @@ model.fit(x_train, y_train.values.ravel())
|
|
92 |
y_pred = model.predict(x_test)
|
93 |
|
94 |
|
95 |
-
### -------------------------------- ###
|
96 |
-
### article generation ###
|
97 |
-
### -------------------------------- ###
|
98 |
-
# borrow file reading function from reader.py
|
99 |
-
|
100 |
-
# def get_feat():
|
101 |
-
# feats = [abs(x) for x in model.coef_[0]]
|
102 |
-
# max_val = max(feats)
|
103 |
-
# idx = feats.index(max_val)
|
104 |
-
# return data.columns[idx]
|
105 |
-
|
106 |
-
# acc = str(round(metrics.accuracy_score(y_test, y_pred) * 100, 1)) + '%**'
|
107 |
-
# most_imp_feat = get_feat() + "**"
|
108 |
-
# info = get_article(acc, most_imp_feat)
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
### ------------------------------- ###
|
113 |
### interface creation ###
|
114 |
### ------------------------------- ###
|
@@ -141,13 +122,16 @@ for colname in data.columns:
|
|
141 |
# otherwise, just use a number input
|
142 |
if colname in cat_value_dicts:
|
143 |
radio_options = list(cat_value_dicts[colname].keys())
|
144 |
-
inputls.append(
|
145 |
else:
|
146 |
# add numerical input
|
147 |
-
inputls.append(
|
148 |
|
149 |
# generate gradio interface
|
150 |
if col2.button("Submit"):
|
151 |
prediction = general_predictor(inputls)
|
152 |
|
153 |
-
|
|
|
|
|
|
|
|
14 |
### interface setup ###
|
15 |
### ----------------------------- ###
|
16 |
|
|
|
|
|
17 |
with open('styles.css') as f:
|
18 |
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
19 |
|
20 |
+
st.markdown('###Mental Health App')
|
21 |
+
st.markdown('##A machine learning app by Isabel')
|
22 |
|
23 |
|
24 |
### ------------------------------ ###
|
|
|
90 |
y_pred = model.predict(x_test)
|
91 |
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
### ------------------------------- ###
|
94 |
### interface creation ###
|
95 |
### ------------------------------- ###
|
|
|
122 |
# otherwise, just use a number input
|
123 |
if colname in cat_value_dicts:
|
124 |
radio_options = list(cat_value_dicts[colname].keys())
|
125 |
+
inputls.append(st.selectbox(colname, radio_options))
|
126 |
else:
|
127 |
# add numerical input
|
128 |
+
inputls.append(st.number_imput(colname))
|
129 |
|
130 |
# generate gradio interface
|
131 |
if col2.button("Submit"):
|
132 |
prediction = general_predictor(inputls)
|
133 |
|
134 |
+
st.text(f"Your recommendation: {prediction}")
|
135 |
+
|
136 |
+
with open('info.md') as f:
|
137 |
+
st.markdown(f.read())
|