├── requirements.txt
├── images
├── head.png
└── photo_2021-09-20_17-45-36.jpg
├── model
├── saved_model.pb
├── keras_metadata.pb
└── variables
│ ├── variables.index
│ └── variables.data-00000-of-00001
├── readme.md
└── app.py
/requirements.txt:
--------------------------------------------------------------------------------
1 | numpy
2 | pandas
3 | tensorflow
4 | streamlit
5 |
--------------------------------------------------------------------------------
/images/head.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mehrdad-dev/anxiety-predict/HEAD/images/head.png
--------------------------------------------------------------------------------
/model/saved_model.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mehrdad-dev/anxiety-predict/HEAD/model/saved_model.pb
--------------------------------------------------------------------------------
/model/keras_metadata.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mehrdad-dev/anxiety-predict/HEAD/model/keras_metadata.pb
--------------------------------------------------------------------------------
/model/variables/variables.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mehrdad-dev/anxiety-predict/HEAD/model/variables/variables.index
--------------------------------------------------------------------------------
/images/photo_2021-09-20_17-45-36.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mehrdad-dev/anxiety-predict/HEAD/images/photo_2021-09-20_17-45-36.jpg
--------------------------------------------------------------------------------
/model/variables/variables.data-00000-of-00001:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mehrdad-dev/anxiety-predict/HEAD/model/variables/variables.data-00000-of-00001
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Anxiety prediction using deep learning based on the Taylor Manifest Anxiety Scale
5 |
6 | [](https://share.streamlit.io/mehrdad-dev/anxiety-predict/main/app.py)
7 |
8 |
9 | ------------------------
10 |
11 |
12 | # Anxiety Prediction
13 | Based on the Taylor Manifest Anxiety Scale
14 |
15 | I provide a deep learning model for predicting the anxiety level of a person based on the Taylor Manifest Anxiety Scale. This test was published by `Taylor, J.A` in the paper [A personality scale of manifest anxiety (1953)](https://sci-hub.se/https://doi.org/10.1037/h0056264).
16 |
17 |
18 | ## Demo Website
19 | Go to the [website](https://share.streamlit.io/mehrdad-dev/anxiety-predict/main/app.py) to fill test and get a prediction!
20 |
21 | ## 🤖 Model
22 |
23 | You can access the model [here](https://github.com/mehrdad-dev/anxiety-predict/tree/main/model).
24 |
25 | model version: 2.0
26 | model metrics: mse: 0.0253 - mae: 0.1163 - root_mean_squared_error: 0.1590
27 |
28 | train loss vs validation loss:
29 |
30 |
31 |
32 | ## 📊 Data
33 |
34 | You can access the data [here](http://openpsychometrics.org/_rawdata/TMA.zip). This file contains the data without preprocessing.
35 |
36 | Number of samples: 5410
37 |
--------------------------------------------------------------------------------
/app.py:
--------------------------------------------------------------------------------
1 | import streamlit as st
2 | import numpy as np
3 | import pandas as pd
4 | import tensorflow as tf
5 |
6 | st.title('Anxiety Prediction')
7 | st.markdown('Based on Taylor Manifest Anxiety Scale by [mehrdad-dev](https://mehrdad-dev.github.io)', unsafe_allow_html=True)
8 |
9 | about = """
10 | I provide a deep learning model for predicting the anxiety level of a person based on the Taylor Manifest Anxiety Scale.
11 | This test was published by `Taylor, J.A` in paper [A personality scale of manifest anxiety (1953)](https://sci-hub.se/https://doi.org/10.1037/h0056264).
12 |
13 | ### 🌟 If you like it ...
14 | Thanks!, If you like/use this project, give it a star on [GitHub](https://github.com/mehrdad-dev/anxiety-predict)!
15 | """
16 | st.markdown(about, unsafe_allow_html=True)
17 |
18 | expander = st.expander("🤖 Model ")
19 | model_ex = """
20 | You can access the model [here](https://github.com/mehrdad-dev/anxiety-predict/tree/main/model).
21 | - model version: 2.0
22 | - model metrics: mse: 0.0253 - mae: 0.1163 - root_mean_squared_error: 0.1590
23 | """
24 | expander.markdown(model_ex)
25 |
26 | expander = st.expander("📊 Data")
27 | data_ex = """
28 | You can access the data [here](http://openpsychometrics.org/_rawdata/TMA.zip). This file contains the data without preprocessing.
29 | - Number of samples: 5410
30 | """
31 | expander.markdown(data_ex)
32 |
33 |
34 | st.markdown(' ', unsafe_allow_html=True)
35 |
36 |
37 | st.markdown('## ❗️ Notes:', unsafe_allow_html=True)
38 | notes = """
39 | - This Test has 50 questions with True/False answers.
40 | - It takes 4-10 minutes to complete.
41 | - You should answer all the questions.
42 | """
43 | st.markdown(notes, unsafe_allow_html=True)
44 | st.markdown(' ', unsafe_allow_html=True)
45 |
46 | ## ================================================================================================
47 |
48 | answers = []
49 |
50 | def create_model_input(answers):
51 | for key, ans in enumerate(answers):
52 | if ans == 'True':
53 | answers[key] = 1
54 | elif ans == 'False':
55 | answers[key] = 0
56 | else:
57 | answers[key] = ans
58 |
59 | return answers
60 |
61 | ## ================================================================================================
62 |
63 | st.markdown(' How old are you?
', unsafe_allow_html=True)
64 | age = st.slider('', 14, 100, 21)
65 | answers.append(age)
66 |
67 | st.markdown('What is your gender?
', unsafe_allow_html=True)
68 | sex = st.selectbox('', ('Male', 'Female', 'Other'))
69 |
70 | st.markdown('Q1. I do not tire quickly.
', unsafe_allow_html=True)
71 | q1 = st.selectbox('', ('True', 'False'), key='q1')
72 | answers.append(q1)
73 |
74 | st.markdown('Q2. I am troubled by attacks of nausea.
', unsafe_allow_html=True)
75 | q2 = st.selectbox('', ('True', 'False'), key='q2')
76 | answers.append(q2)
77 |
78 | st.markdown('Q3. I believe I am no more nervous than most others.
', unsafe_allow_html=True)
79 | q3 = st.selectbox('', ('True', 'False'), key='q3')
80 | answers.append(q3)
81 |
82 | st.markdown('Q4. I have very few headaches.
', unsafe_allow_html=True)
83 | q4 = st.selectbox('', ('True', 'False'), key='q4')
84 | answers.append(q4)
85 |
86 | st.markdown('Q5. I work under a great deal of tension.
', unsafe_allow_html=True)
87 | q5 = st.selectbox('', ('True', 'False'), key='q5')
88 | answers.append(q5)
89 |
90 | st.markdown('Q6. I cannot keep my mind on one thing.
', unsafe_allow_html=True)
91 | q6 = st.selectbox('', ('True', 'False'), key='q6')
92 | answers.append(q6)
93 |
94 | st.markdown('Q7. I worry over money and business.
', unsafe_allow_html=True)
95 | q7 = st.selectbox('', ('True', 'False'), key='q7')
96 | answers.append(q7)
97 |
98 | st.markdown('Q8. I frequently notice my hand shakes when I try to do something.
', unsafe_allow_html=True)
99 | q8 = st.selectbox('', ('True', 'False'), key='q8')
100 | answers.append(q8)
101 |
102 | st.markdown(' Q9. I blush no more often than others.
', unsafe_allow_html=True)
103 | q9 = st.selectbox('', ('True', 'False'), key='q9')
104 | answers.append(q9)
105 |
106 | st.markdown('Q10. I have diarrhea once a month or more.
', unsafe_allow_html=True)
107 | q10 = st.selectbox('', ('True', 'False'), key='q10')
108 | answers.append(q10)
109 |
110 | st.markdown('Q11. I worry quite a bit over possible misfortunes.
', unsafe_allow_html=True)
111 | q11 = st.selectbox('', ('True', 'False'), key='q11')
112 | answers.append(q11)
113 |
114 | st.markdown(' Q12. I practically never blush.
', unsafe_allow_html=True)
115 | q12 = st.selectbox('', ('True', 'False'), key='q12')
116 | answers.append(q12)
117 |
118 | st.markdown('Q13. I am often afraid that I am going to blush.
', unsafe_allow_html=True)
119 | q13 = st.selectbox('', ('True', 'False'), key='q13')
120 | answers.append(q13)
121 |
122 | st.markdown('Q14. I have nightmares every few nights.
', unsafe_allow_html=True)
123 | q14 = st.selectbox('', ('True', 'False'), key='q14')
124 | answers.append(q14)
125 |
126 | st.markdown('Q15. My hands and feet are usually warm.
', unsafe_allow_html=True)
127 | q15 = st.selectbox('', ('True', 'False'), key='q15')
128 | answers.append(q15)
129 |
130 | st.markdown(' Q16. I sweat very easily even on cool days.
', unsafe_allow_html=True)
131 | q16 = st.selectbox('', ('True', 'False'), key='q16')
132 | answers.append(q16)
133 |
134 | st.markdown(' Q17. Sometimes when embarrassed, I break out in a sweat.
', unsafe_allow_html=True)
135 | q17 = st.selectbox('', ('True', 'False'), key='q17')
136 | answers.append(q17)
137 |
138 | st.markdown('Q18. I hardly ever notice my heart pounding and I am seldom short of breath.
', unsafe_allow_html=True)
139 | q18 = st.selectbox('', ('True', 'False'), key='q18')
140 | answers.append(q18)
141 |
142 | st.markdown(' Q19. I feel hungry almost all the time.
', unsafe_allow_html=True)
143 | q19 = st.selectbox('', ('True', 'False'), key='q19')
144 | answers.append(q19)
145 |
146 | st.markdown('Q20. I am very seldom troubled by constipation.
', unsafe_allow_html=True)
147 | q20 = st.selectbox('', ('True', 'False'), key='q20')
148 | answers.append(q20)
149 |
150 | st.markdown('Q21. I have a great deal of stomach trouble.
', unsafe_allow_html=True)
151 | q21 = st.selectbox('', ('True', 'False'), key='q21')
152 | answers.append(q21)
153 |
154 | st.markdown('Q22. I have had periods in which I lost sleep over worry.
', unsafe_allow_html=True)
155 | q22 = st.selectbox('', ('True', 'False'), key='q22')
156 | answers.append(q22)
157 |
158 | st.markdown('Q23. My sleep is fitful and disturbed.
', unsafe_allow_html=True)
159 | q23 = st.selectbox('', ('True', 'False'), key='q23')
160 | answers.append(q23)
161 |
162 | st.markdown('Q24. I dream frequently about things that are best kept to myself.
', unsafe_allow_html=True)
163 | q24 = st.selectbox('', ('True', 'False'), key='q24')
164 | answers.append(q24)
165 |
166 | st.markdown('Q25. I am easily embarrassed.
', unsafe_allow_html=True)
167 | q25 = st.selectbox('', ('True', 'False'), key='q25')
168 | answers.append(q25)
169 |
170 | st.markdown('Q26. I am more sensitive than most other people.
', unsafe_allow_html=True)
171 | q26 = st.selectbox('', ('True', 'False'), key='q26')
172 | answers.append(q26)
173 |
174 | st.markdown('Q27. I frequently find myself worrying about something.
', unsafe_allow_html=True)
175 | q27 = st.selectbox('', ('True', 'False'), key='q27')
176 | answers.append(q27)
177 |
178 | st.markdown('Q28. I wish I could be as happy as others seem to be.
', unsafe_allow_html=True)
179 | q28 = st.selectbox('', ('True', 'False'), key='q28')
180 | answers.append(q28)
181 |
182 | st.markdown('Q29. I am usually calm and not easily upset.
', unsafe_allow_html=True)
183 | q29 = st.selectbox('', ('True', 'False'), key='q29')
184 | answers.append(q29)
185 |
186 | st.markdown('Q30. I cry easily.
', unsafe_allow_html=True)
187 | q30 = st.selectbox('', ('True', 'False'), key='q30')
188 | answers.append(q30)
189 |
190 | st.markdown('Q31. I feel anxiety about something or someone almost all the time.
', unsafe_allow_html=True)
191 | q31 = st.selectbox('', ('True', 'False'), key='q31')
192 | answers.append(q31)
193 |
194 | st.markdown('Q32. I am happy most of the time.
', unsafe_allow_html=True)
195 | q32 = st.selectbox('', ('True', 'False'), key='q32')
196 | answers.append(q32)
197 |
198 | st.markdown('Q33. It makes me nervous to have to wait.
', unsafe_allow_html=True)
199 | q33 = st.selectbox('', ('True', 'False'), key='q33')
200 | answers.append(q33)
201 |
202 | st.markdown('Q34. I have periods of such great restlessness that I cannot sit long I a chair.
', unsafe_allow_html=True)
203 | q34 = st.selectbox('', ('True', 'False'), key='q34')
204 | answers.append(q34)
205 |
206 | st.markdown('Q35. Sometimes I become so excited that I find it hard to get to sleep.
', unsafe_allow_html=True)
207 | q35 = st.selectbox('', ('True', 'False'), key='q35')
208 | answers.append(q35)
209 |
210 | st.markdown('Q36. I have sometimes felt that difficulties were piling up so high that I could not overcome them.
', unsafe_allow_html=True)
211 | q36 = st.selectbox('', ('True', 'False'), key='q36')
212 | answers.append(q36)
213 |
214 | st.markdown('Q37. I must admit that I have at times been worried beyond reason over something that really did not matter.
', unsafe_allow_html=True)
215 | q37 = st.selectbox('', ('True', 'False'), key='q37')
216 | answers.append(q37)
217 |
218 | st.markdown('Q38. I have very few fears compared to my friends.
', unsafe_allow_html=True)
219 | q38 = st.selectbox('', ('True', 'False'), key='q38')
220 | answers.append(q38)
221 |
222 | st.markdown('Q39. I have been afraid of things or people that I know could not hurt me.
', unsafe_allow_html=True)
223 | q39 = st.selectbox('', ('True', 'False'), key='q39')
224 | answers.append(q39)
225 |
226 | st.markdown('Q40. I certainly feel useless at times.
', unsafe_allow_html=True)
227 | q40 = st.selectbox('', ('True', 'False'), key='q40')
228 | answers.append(q40)
229 |
230 | st.markdown('Q41. I find it hard to keep my mind on a task or job.
', unsafe_allow_html=True)
231 | q41 = st.selectbox('', ('True', 'False'), key='q41')
232 | answers.append(q41)
233 |
234 | st.markdown('Q42. I am usually self-conscious.
', unsafe_allow_html=True)
235 | q42 = st.selectbox('', ('True', 'False'), key='q42')
236 | answers.append(q42)
237 |
238 | st.markdown('Q43. I am inclined to take things hard.
', unsafe_allow_html=True)
239 | q43 = st.selectbox('', ('True', 'False'), key='q43')
240 | answers.append(q43)
241 |
242 | st.markdown('Q44. I am a high-strung person.
', unsafe_allow_html=True)
243 | q44 = st.selectbox('', ('True', 'False'), key='q44')
244 | answers.append(q44)
245 |
246 | st.markdown('Q45. Life is a trial for me much of the time.
', unsafe_allow_html=True)
247 | q45 = st.selectbox('', ('True', 'False'), key='q45')
248 | answers.append(q45)
249 |
250 | st.markdown('Q46. At times I think I am no good at all.
', unsafe_allow_html=True)
251 | q46 = st.selectbox('', ('True', 'False'), key='q46')
252 | answers.append(q46)
253 |
254 | st.markdown('Q47. I am certainly lacking in self-confidence.
', unsafe_allow_html=True)
255 | q47 = st.selectbox('', ('True', 'False'), key='q47')
256 | answers.append(q47)
257 |
258 | st.markdown('Q48. I sometimes feel that I am about to go to pieces.
', unsafe_allow_html=True)
259 | q48 = st.selectbox('', ('True', 'False'), key='q48')
260 | answers.append(q48)
261 |
262 | st.markdown(' Q49. I shrink from facing crisis of difficulty.
', unsafe_allow_html=True)
263 | q49 = st.selectbox('', ('True', 'False'), key='q49')
264 | answers.append(q49)
265 |
266 | st.markdown('Q50. I am entirely self-confident.
', unsafe_allow_html=True)
267 | q50 = st.selectbox('', ('True', 'False'), key='q50')
268 | answers.append(q50)
269 |
270 |
271 | if sex == 'Female':
272 | answers.append(1)
273 | answers.append(0)
274 | answers.append(0)
275 | elif sex == 'Male':
276 | answers.append(0)
277 | answers.append(1)
278 | answers.append(0)
279 | else:
280 | answers.append(0)
281 | answers.append(0)
282 | answers.append(1)
283 |
284 |
285 | left_column, right_column = st.columns(2)
286 | pressed = left_column.button('Predict!')
287 | if pressed:
288 | model_input = create_model_input(answers)
289 | model = tf.keras.models.load_model('model')
290 | model_input = np.array([model_input])
291 | temp_df = pd.DataFrame(model_input)
292 | pred = model.predict(temp_df)
293 | st.info('Your score is: ' + str(pred[0][0]) + ' of 50')
294 | st.info('Scores higher than 25 indicate abnormal levels on anxiety.')
295 |
296 | # st.info('This is a purely informational message')
297 | #title = st.text_input('Movie title', 'Life of Brian')
298 |
299 |
300 | img = st.sidebar.image('images/head.png', width=200)
301 | st.sidebar.markdown('## **Project Links:**', unsafe_allow_html=True)
302 | st.sidebar.markdown('[GitHub](https://github.com/mehrdad-dev/anxiety-predict)', unsafe_allow_html=True)
303 | st.sidebar.markdown('[Website](https://mehrdad-dev.github.io)', unsafe_allow_html=True)
304 |
--------------------------------------------------------------------------------