Sudheer commited on
Commit
d11985a
1 Parent(s): a3cfa1a

Create new file

Browse files
Files changed (1) hide show
  1. app.py +326 -0
app.py ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pandas as pd
4
+ from transformers import pipeline
5
+ from wordcloud import WordCloud
6
+ import matplotlib.pyplot as plt
7
+ import nltk
8
+ from nltk.corpus import stopwords
9
+ from nltk.tokenize import word_tokenize
10
+ nltk.download('punkt')
11
+ nltk.download('stopwords')
12
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
13
+ def calculate(q1,q2,q3,q4,q5,q6,q7,q8,q9,q10):
14
+ score = 0
15
+ for i in [q4,q5,q7,q8]:
16
+ if i == 'Very Often':
17
+ score += 0
18
+ elif i == 'Fairly Often':
19
+ score += 1
20
+ elif i == 'Sometimes':
21
+ score += 2
22
+ elif i == 'Almost':
23
+ score += 3
24
+ elif i == 'Never':
25
+ score += 4
26
+ for i in [q1,q2,q3,q6,q9,q10]:
27
+ if i == 'Very Often':
28
+ score += 4
29
+ elif i == 'Fairly Often':
30
+ score += 3
31
+ elif i == 'Sometimes':
32
+ score += 2
33
+ elif i == 'Almost':
34
+ score += 1
35
+ elif i == 'Never':
36
+ score += 0
37
+ return score
38
+ def home_page():
39
+ st.write("# Mental Health Well Being App! \U0001f64f")
40
+ st.markdown(
41
+ """
42
+ TBD
43
+ This is a place for you to check your stress score based on the Perceived Stress Score (PSS)).
44
+ **👈 Select our offerings from the dropdown on the left** to see how we can help!
45
+ """
46
+ )
47
+ def PSS_monthly():
48
+ st.write("## Ready to know your score on Perceived Stress Scale (PSS) for this month?")
49
+ st.markdown("""This tool assess how different situations affect your feelings and your perceived stress. The questions in this scale ask about your feelings and thoughts during the last month.""")
50
+ st.sidebar.success("Select one of our offerings from above. For better results, follow the sequence")
51
+ st.sidebar.image("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBYWFRgWFRYYGRgYGR4cHBwcGBoaHB0cGhgaGhoaGhweIS4nHCErIRocJjgmKy8xNTU1GiQ7QDs0Py40NTEBDAwMEA8QHBISHTQrJSs2NDQ0NDQ0NDY0NDQ0NDE0NDQ0NTQ0NDQ0NDQ0NDQ0NDQ0NDE0MTQ0NDQ0NDE0NDQ0NP/AABEIAP0AxwMBIgACEQEDEQH/xAAcAAEAAQUBAQAAAAAAAAAAAAAABwIDBAUGAQj/xABAEAACAQIDBgMGBAQFAgcAAAABAgADEQQSIQUGMUFRYSJxgQcTMpGhsUJSYtEUksHwcoKy4fEjwhUWMzREY6L/xAAZAQEBAQEBAQAAAAAAAAAAAAAAAQIDBAX/xAAgEQEBAAICAwADAQAAAAAAAAAAAQIRAyESMUEEE1Fh/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PxHlLVT2X4lvixafyOf+4SV4mJxYT4155Iow3smqDRsdYcwlIjXTmanQdJ2G6W51HAl2R6lR6gAZnI4LcgKABbies6eJuSRnZIT2/tk/wAVUvmS1Vgyka2DEa9dALSbJgY3ZdCt/wCrRp1P8SKxHkSNJz5eOZzVawy8aiCpvSBSdUOufMoIOt1UE9NANPWaTE7wMwGYi/O2nPThzk0tuVgD/wDFp+gIHyBtKqO5uAU3GEoE/qQN/qvOGP4eEu3TLmtRHuxttnxNBFpvVYVVJCi9hnF3Nr2AGp5aSepaw+GRBZFVR0VQo+Ql2erHHUcbdvYiJpCIiAiIgIiIH//Z",use_column_width=True
52
+ )
53
+
54
+ with st.form(key='Questionaire_monthly'):
55
+ question1 = st.selectbox(
56
+ '1. In the last month, how often have you been upset because of something that happened unexpectedly?',
57
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
58
+ question2 = st.selectbox(
59
+ '2. In the last month, how often have you felt that you were unable to control the important things in your life?',
60
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
61
+ question3 = st.selectbox(
62
+ '3. In the last month, how often have you felt nervous and "stressed"?',
63
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
64
+ question4 = st.selectbox(
65
+ '4. In the last month, how often have you felt confident about your ability to handle your personal problems?',
66
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
67
+ question5 = st.selectbox(
68
+ '5. In the last month, how often have you felt that things were going your way?',
69
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
70
+ question6 = st.selectbox(
71
+ '6. In the last month, how often have you found that you could not cope with all the things that you had to do?',
72
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
73
+ question7 = st.selectbox(
74
+ '7. In the last month, how often have you been able to control irritations in your life?',
75
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
76
+ question8 = st.selectbox(
77
+ '8. In the last month, how often have you felt that you were on top of things?',
78
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
79
+ question9 = st.selectbox(
80
+ '9. In the last month, how often have you been angered because of things that were outside of your control?',
81
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
82
+ question10 = st.selectbox(
83
+ '10. In the last month, how often have you felt difficulties were piling up so high that you could not overcome them?',
84
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
85
+ submit_button = st.form_submit_button(label='Submit')
86
+ if submit_button:
87
+ score = calculate(question1,question2,question3,question4,question5,question6,question7,question8,question9,question10)
88
+ st.write(f'Your Stress score : {score}/40 ')
89
+ st.markdown("""**Here is how you progressed in the previous months**""")
90
+ #Synthetic data created for the given user for 6 days
91
+ df = pd.DataFrame(np.random.randint(10,40,(8,1)),columns=["Score"])
92
+ df['Month'] = ['01/01','02/01','03/01','04/01','05/01','06/01','07/01','08/01']
93
+ df.loc[7, 'Score'] = score
94
+ df = df.set_index('Month')
95
+ st.bar_chart(df)
96
+ st.markdown("""---""")
97
+ st.markdown("""Worried that you are a victim of stress? ***You are not alone*** and we are in a shared space.""")
98
+ st.markdown("""How other users stand with you in Stress levels""")
99
+ #Synthetic data created for other users
100
+ members_scores = pd.DataFrame(np.random.randint(0,40,(40,2)),columns=['score','count'])
101
+ members_scores = members_scores.groupby(['score'])['count'].agg('sum').reset_index()#.rename(columns={'count':'No. of Users'})
102
+ #st.dataframe(members_scores)
103
+ #if score in members_scores['score']:
104
+ # members_scores.loc[len(members_scores.index)]= [score,1+members_scores[members_scores['score']==score]['No. of Users']]
105
+ #else:
106
+ # members_scores.loc[len(members_scores.index)]= [score,1]
107
+ #st.dataframe(members_scores)
108
+ #fig = plt.figure(figsize=(10, 4))
109
+ #plt.scatter(members_scores['score'], members_scores['No. of Users'],s=[5*i for i in members_scores['No. of Users']])
110
+ #plt.scatter(score,members_scores[members_scores['score']==score]['No. of Users'],marker="*",color='r')
111
+ #st.balloons()
112
+ #plt.xlabel('Perceived Stress Scale')
113
+ #plt.ylabel('No. of Users')
114
+ #st.pyplot(fig)
115
+ #st.markdown("""---""")
116
+ st.vega_lite_chart(members_scores, {
117
+ 'mark': {'type': 'circle', 'tooltip': True},
118
+ 'encoding': {
119
+ 'x': {'field': 'score', 'type': 'quantitative'},
120
+ 'y': {'field': 'count', 'type': 'quantitative'},
121
+ 'size': {'field': 'score', 'type': 'quantitative'},
122
+ 'color': {'field': 'score', 'type': 'quantitative'},
123
+ },
124
+ },use_container_width=True)
125
+
126
+ def PSS():
127
+ st.write("## Ready to know your score on Perceived Stress Scale (PSS) for this week?")
128
+ st.markdown("""This tool assess how different situations affect your feelings and your perceived stress. The questions in this scale ask about your feelings and thoughts during the last week.""")
129
+ st.sidebar.success("Select one of our offerings from above. For better results, follow the sequence")
130
+ st.sidebar.image("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBYWFRgWFRYYGRgYGR4cHBwcGBoaHB0cGhgaGhoaGhweIS4nHCErIRocJjgmKy8xNTU1GiQ7QDs0Py40NTEBDAwMEA8QHBISHTQrJSs2NDQ0NDQ0NDY0NDQ0NDE0NDQ0NTQ0NDQ0NDQ0NDQ0NDQ0NDE0MTQ0NDQ0NDE0NDQ0NP/AABEIAP0AxwMBIgACEQEDEQH/xAAcAAEAAQUBAQAAAAAAAAAAAAAABwIDBAUGAQj/xABAEAACAQIDBgMGBAQFAgcAAAABAgADEQQSIQUGMUFRYSJxgQcTMpGhsUJSYtEUksHwcoKy4fEjwhUWMzREY6L/xAAZAQEBAQEBAQAAAAAAAAAAAAAAAQIDBAX/xAAgEQEBAAICAwADAQAAAAAAAAAAAQIRAyESMUEEE1Fh/9oADAMBAAIRAxEAPwCZoiICIiAiIgIiICJC++e/OMTFVqdGp7tab5AAqm+U8TmB1JPK3Kdz7Pt6/wCOw7M4Aq0iFe3A3F1cDlex06gybXTromO+LA4ayg439Jk8oi/VqKqlmICqCSTwAAuSfSRltL2u01fLRos6A/EzZSw/SttPU+k7fa9cVaFWlYg1KbqOl2QgX+cgmn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/O2nPThzk0tuVgD/wDFp+gIHyBtKqO5uAU3GEoE/qQN/qvOGP4eEu3TLmtRHuxttnxNBFpvVYVVJCi9hnF3Nr2AGp5aSepaw+GRBZFVR0VQo+Ql2erHHUcbdvYiJpCIiAiIgIiIH//Z",use_column_width=True
131
+ )
132
+ with st.form(key='Questionaire'):
133
+ question1 = st.selectbox(
134
+ '1. In the last week, how often have you been upset because of something that happened unexpectedly?',
135
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
136
+ question2 = st.selectbox(
137
+ '2. In the last week, how often have you felt that you were unable to control the important things in your life?',
138
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
139
+ question3 = st.selectbox(
140
+ '3. In the last week, how often have you felt nervous and "stressed"?',
141
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
142
+ question4 = st.selectbox(
143
+ '4. In the last week, how often have you felt confident about your ability to handle your personal problems?',
144
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
145
+ question5 = st.selectbox(
146
+ '5. In the last week, how often have you felt that things were going your way?',
147
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
148
+ question6 = st.selectbox(
149
+ '6. In the last week, how often have you found that you could not cope with all the things that you had to do?',
150
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
151
+ question7 = st.selectbox(
152
+ '7. In the last week, how often have you been able to control irritations in your life?',
153
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
154
+ question8 = st.selectbox(
155
+ '8. In the last week, how often have you felt that you were on top of things?',
156
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
157
+ question9 = st.selectbox(
158
+ '9. In the last week, how often have you been angered because of things that were outside of your control?',
159
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
160
+ question10 = st.selectbox(
161
+ '10. In the last week, how often have you felt difficulties were piling up so high that you could not overcome them?',
162
+ ('Very Often', 'Fairly Often', 'Sometimes','Almost','Never'))
163
+ submit_button = st.form_submit_button(label='Submit')
164
+ if submit_button:
165
+ score = calculate(question1,question2,question3,question4,question5,question6,question7,question8,question9,question10)
166
+ st.write(f'Your Stress score : {score}/40 ')
167
+ def daily_log():
168
+ model_path = "cardiffnlp/twitter-xlm-roberta-base-sentiment"
169
+ sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)
170
+ st.markdown("""***Hey there!! 👋 Ready to track your daily progress*** \u270D\uFE0F""")
171
+ with st.form(key='Sentiment'):
172
+ prompt = st.text_area('Thought Journal:',value="Hackathon was the best part of today and collaborating with colleagues is icing on the cake. It was challenging though.")
173
+ submit_button = st.form_submit_button(label='Submit')
174
+ if submit_button:
175
+ out = sentiment_task(prompt)
176
+ if out[0]['label'] =='Positive':
177
+ score = out[0]['score']
178
+ st.write(f'Yay!! You are having a great day and we know that you are worth of it \U0001f60d')
179
+ elif out[0]['label'] =='Negative':
180
+ st.write("Sorry you had a bad day but you'll always have an another day to improve \U0001f91d \U0001f917")
181
+ habit = st.selectbox('Did you stick with the habit?',('Yes', 'No'))
182
+ history = ["\U0001F612","\U0001F600","\U0001F600","\U0001F612","\U0001F600","\U0001F612"]
183
+ days = ['Day1', 'Day2', 'Day3', 'Day4', 'Day5', 'Day6']
184
+ button = st.button('Track',key='hbt_button')
185
+ df = pd.DataFrame(list(zip(days, history)), columns =['Days','Emotions'])
186
+ df = df.set_index('Days')
187
+ if button:
188
+ if habit=='Yes':
189
+ st.write("Well Done, Keep it up!! \u2705")
190
+ df.loc['Day7'] = ["\U0001F600"]
191
+ elif habit=='No':
192
+ st.write("Don't worry, you can catch up again tomorrow")
193
+ df.loc['Day7'] = ["\U0001F612"]
194
+ #st.bar_chart(df)
195
+ #Steps Calculator
196
+ st.markdown("""---""")
197
+ no_of_steps = st.text_input('Steps Walked Today', 0)
198
+ no_of_steps = int(no_of_steps)
199
+ stp_history = [5000,1250,4850,1890,6000,4500]
200
+ stp_days = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5', 'Day 6']
201
+ stp_button = st.button('Track',key='stp_button')
202
+ stp_df = pd.DataFrame(list(zip(stp_days, stp_history)), columns =['Days','Steps'])
203
+ stp_df = stp_df.set_index('Days')
204
+ if stp_button:
205
+ if no_of_steps>=0:
206
+ st.write("Well Done, Keep it up!! \u2705")
207
+ stp_df.loc['Day7'] = [no_of_steps]
208
+ st.markdown("""---""")
209
+ # Sleep
210
+ no_of_hrs = st.text_input('Hours Slept', '0')
211
+ no_of_hrs = int(no_of_hrs)
212
+ hrs_history = [7,7.5,8,7.5,6,8]
213
+ hrs_days = ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5', 'Day 6']
214
+ slp_button = st.button('Track',key='slp_button')
215
+ slp_df = pd.DataFrame(list(zip(hrs_days, hrs_history)), columns =['Days','Hours slept'])
216
+ slp_df = slp_df.set_index('Days')
217
+ if slp_button:
218
+ if no_of_hrs>=0:
219
+ st.write("Well Done, Keep it up!! \u2705")
220
+ slp_df.loc['Day7'] = [no_of_hrs]
221
+
222
+ #slp_df = slp_df.copy(deep=False)
223
+ #st.dataframe(slp_df)
224
+ st.markdown("""---""")
225
+ st.markdown("""**Gratitude Journal**""")
226
+ st.markdown("""Use the below prompt and reflect on what you are grateful for today. We will provide you our insights \U0001f929 """)
227
+ gratitude = st.text_area('I am grateful for ....',value='the wonderful family I am gifted with. They are always supportive and encourage to achieve my goals.')
228
+ grt_button = st.button('Get me things that I love the most',key='grt_button')
229
+ if grt_button:
230
+ #Synthetic data
231
+ grt_text = 'Family Trip Friends Books College Movies friendship friendship Food Gatherings School Rain Nature Discipline Compassionate laugh, joy , excellent, relaxing, food, cakes, chocolates, sweets, festival, Family Family Family hilarious, weekends, Movies friendship, love rainbow, comedy affection vacation beach dance sports attractive optimistic moonlight, bonus ' + gratitude
232
+
233
+ stop_words = set(stopwords.words('english'))
234
+ word_tokens = word_tokenize(grt_text)
235
+
236
+ filtered_sentence = [w for w in word_tokens if not w.lower() in stop_words]
237
+ filtered_sentence = []
238
+ for w in word_tokens:
239
+ if w not in stop_words and len(w)>3 :
240
+ filtered_sentence.append(w)
241
+ filtered_words = ' '.join(map(str,filtered_sentence))
242
+ wordcloud = WordCloud().generate(filtered_words)
243
+ # Display the generated image:
244
+ plt.imshow(wordcloud, interpolation='bilinear')
245
+ plt.axis("off")
246
+ plt.show()
247
+ st.set_option('deprecation.showPyplotGlobalUse', False)
248
+ st.markdown("""**We found these to be your favourites**""" +""" \U0001f60d""")
249
+ st.pyplot()
250
+ st.markdown("""**May be you should doing things that makes you grateful**""" +""" \U0001f596""")
251
+ st.markdown("""\n""")
252
+ st.markdown("""---""")
253
+ st.markdown("""**Want to know how you are doing in this week ?**""" +""" \U0001f4c8""")
254
+ trd_button = st.button('Display Trends',key='trds_button')
255
+ if trd_button:
256
+ st.markdown("""**How your emotions varied in this week ?**""" +""" \U0001F612 \U0001F600""")
257
+ st.bar_chart(df)
258
+ st.markdown("""---""")
259
+ st.markdown("""**Track of your step count in this week ?**""" +""" \U0001f45f""")
260
+ st.line_chart(stp_df)
261
+ st.markdown("""---""")
262
+ st.markdown("""**Track of hours you slept in this week ?**""" +""" \U0001f4a4""")
263
+ st.line_chart(slp_df)
264
+ st.markdown("""---""")
265
+ check_box_prb = st.checkbox('I have completed my 7 days of tracking and I am ready to know your recomendation')
266
+ #st.dataframe(slp_df)
267
+ if check_box_prb:
268
+ slp_df = slp_df.copy(deep=False)
269
+ #if slp_df.shape[0] == 7:
270
+ #st.write(slp_df.shape[0])
271
+ st.write("That's Awesome! Keep the momentum going!")
272
+ st.markdown("""**Why don't you share what you are going through? This would help us to give a better recommendation**""")
273
+ classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-distilroberta-base')
274
+ sent = st.text_area('Brief your problem, we will suggest activities that could help you overcome stress',value="""As I am in college I am up all night all day getting only 5 hours of sleep daily. Eventually after some days I started facing some issues like mood swings and feeling lazy all the time , body ache, puffy eyes and ended up eating at night (one becomes snacky resulting at night) in weight gain.""")
275
+ prb_button = st.button(label='Submit',key='probsubmit')
276
+ #slp_df = slp_df.copy(deep=False)
277
+ #st.dataframe(slp_df)
278
+ if prb_button:
279
+ #st.dataframe(slp_df)
280
+ #slp_df = slp_df.copy(deep=False)
281
+ candidate_labels = ["Sleep-disorder", "Work-stress", "Peer pressure"]
282
+ res = classifier(sent, candidate_labels)
283
+ problem = res['labels'][0]
284
+ st.write('We feel working on ',problem ,' could improve your overall well-being')
285
+ st.markdown("""###Not sure where to start?###"""+ """ \U0001f914 """+""" ###Here are our recommendations!!### \U0001f917""")
286
+ if problem == 'Sleep-disorder':
287
+ st.write("Try this [Mediatation for Sleep on Headspace](https://www.headspace.com/meditation/sleep)")
288
+ st.write("Try this [Yammer community for Mindfulness](https://web.yammer.com/main/org/optum.com/groups/eyJfdHlwZSI6Ikdyb3VwIiwiaWQiOiI1NzMxOTMxNzUwNCJ9/new)")
289
+ elif problem == 'Work-stress':
290
+ st.write("Try this [Mediatation for Anxiety on Headspace](https://www.headspace.com/meditation/anxiety)")
291
+ st.write("Try this [Yammer community for Mindfulness](https://web.yammer.com/main/org/optum.com/groups/eyJfdHlwZSI6Ikdyb3VwIiwiaWQiOiI1NzMxOTMxNzUwNCJ9/new)")
292
+ elif problem == 'Peer pressure':
293
+ st.write("Try this [Calm Down Meditation](https://www.headspace.com/articles/how-to-calm-down)")
294
+ st.write("Try this [Yammer community for Mindfulness](https://web.yammer.com/main/org/optum.com/groups/eyJfdHlwZSI6Ikdyb3VwIiwiaWQiOiI1NzMxOTMxNzUwNCJ9/new)")
295
+
296
+
297
+ #st.write(type(res['labels']))
298
+ #else:
299
+ # warning = '<p style="font-family:sans-serif; color:Red; font-size: 42px;">Looks like you have not tracked your habits for a week. Instant solutions may not always work. Keep track for atleast 7 days</p>'
300
+ #st.markdown(warning, unsafe_allow_html=True)
301
+ #st.write('Looks like you have not tracked your habits for a week. Instant solutions may not always work. Keep track for atleast 7 days')
302
+
303
+ page_names_to_funcs = {
304
+ "Home": home_page,
305
+ "Daily Log": daily_log,
306
+ "Weekly - Perceived Stress Scale": PSS,
307
+ "Monthly - Perceived Stress Scale": PSS_monthly
308
+ }
309
+
310
+ #st.set_page_config(page_title="Mental Well Being", layout="wide")
311
+ #st.markdown(
312
+ #"""
313
+ #<style>
314
+ # [data-testid="stSidebar"][aria-expanded="true"] > div:first-child{
315
+ # width: 250px;
316
+ # }
317
+ # [data-testid="stSidebar"][aria-expanded="false"] > div:first-child{
318
+ # width: 250px;
319
+ # margin-left: -250px;
320
+ # }
321
+ #
322
+ # """,
323
+ # unsafe_allow_html=True,
324
+ #)
325
+ demo_name = st.sidebar.selectbox("Choose one of our offerings", page_names_to_funcs.keys())
326
+ page_names_to_funcs[demo_name]()