-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
226 lines (207 loc) · 8.05 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import dash
from dash import dcc
from dash import html
import custom_dash_component as cdc
import eda_plots
import pandas as pd
import data_handler as dh
import predict_engine
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__,external_stylesheets=external_stylesheets)
server = app.server
# see https://plotly.com/python/px-arguments/ for more options
questions = dh.get_cdi_field('locationdesc')["locationdesc"].unique()
states = dh.get_cdi_field("question")["question"].unique()
df = dh.get_all_cdi()
dis_ques = df[df["topic"]=="Disability"]["question"].unique()
dis_year = df[df["topic"]=="Disability"]["yearstart"].unique()
diab_ques = df[df["topic"]=="Diabetes"]["question"].unique()
diab_year = df[df["topic"]=="Diabetes"]["yearstart"].unique()
alc_year = df[df["topic"]=="Alcohol"]["yearstart"].unique()
alc_ques = df[df["topic"]=="Alcohol"]["question"].unique()
alc_metric = df[df["topic"]=="Alcohol"]["datavaluetype"].unique()
smoke_year = df[df["topic"]=="Tobacco"]["yearstart"].unique()
smoke_ques = df[df["topic"]=="Tobacco"]["question"].unique()
smoke_metric = df[df["topic"]=="Tobacco"]["datavaluetype"].unique()
stress_year = df[df["topic"]=="Mental Health"]["yearstart"].unique()
stress_ques = df[df["topic"]=="Mental Health"]["question"].unique()
stress_metric = df[df["topic"]=="Mental Health"]["datavaluetype"].unique()
obes_quest = df[df["topic"]=="Nutrition, Physical Activity, and Weight Status"]["question"].unique()
topics = df["topic"].unique()
states_df = dh.get_cdi_cond(
"topic, yearstart, datavaluetype,stratificationcategory1,locationdesc,datavalue,question,locationabbr",
'locationdesc',
dh.us_states
)
app.layout = html.Div([
cdc.explanation_component("introduction.md",header = "Chronic Disease Indicators"),
cdc.explanation_component("eda_1.md",header = "Question Distribution"),
dcc.Dropdown(sorted(questions),style={"width":"100%"},id='state_questions'),
html.Div([
dcc.Graph(
id='questions_plot',
style={
"width":"100%",
"height":"100%",
}
),
],style={
"overflowX":"scroll",
"height":"500px",
"width":"100%"
}),
cdc.explanation_component("eda_2.md",header = "Location Distribution"),
dcc.Dropdown(sorted(states),style={"width":"100%"},id='question_drop',value="all"),
dcc.Graph(
id='locale',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("eda_4.md",header="Presence and Types of Data"),
dcc.Dropdown(sorted(topics),style={"width":"100%"},id='topic_drop',value="Diabetes"),
dcc.Graph(
id='strat',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("eda_3.md",header="Life Expectancy Analysis"),
dcc.Dropdown([2018,2019,2020],style={"width":"100%"},id='le_bar_year',value=2019),
dcc.Graph(
id='le_bar',
style={
"width":"100%",
"height":"70vh",
}
),
dcc.Dropdown([2018,2019,2020],style={"width":"100%"},id='le_map_year',value=2019),
dcc.Graph(
id='le_map',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("sdoh_intro.md",header = "Trends Seen in Social Determinants of Health"),
cdc.explanation_component("disability.md",header = "Comparison of Disability Prevalence"),
dcc.Dropdown(dis_year,style={"width":"100%"},id='dis_bar_year',value=2019),
dcc.Dropdown(dis_ques,style={"width":"100%"},id='dis_bar_ques_drop',value="Adults with any disability"),
dcc.Graph(
id='dis_bar',
style={
"width":"100%",
"height":"70vh",
}
),
dcc.Dropdown(dis_year,style={"width":"100%"},id='dis_map_year',value=2019),
dcc.Dropdown(dis_ques,style={"width":"100%"},id='dis_map_ques_drop',value="Adults with any disability"),
dcc.Graph(
id='dis_map',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("diabetes.md",header = "Comparison of Diabetes Prevalence"),
dcc.Dropdown(diab_year,style={"width":"100%"},id='diab_bar_year',value=2019),
dcc.Dropdown(diab_ques,style={"width":"100%"},id='diab_bar_ques_drop',value="Diabetes among adults"),
dcc.Graph(
id='diab_bar',
style={
"width":"100%",
"height":"70vh",
}
),
dcc.Dropdown(diab_year,style={"width":"100%"},id='diab_map_year',value=2019),
dcc.Dropdown(diab_ques,style={"width":"100%"},id='diab_map_ques_drop',value="Diabetes among adults"),
dcc.Graph(
id='diab_map',
style={
"width":"100%",
"height":"70vh",
}
),
dcc.Dropdown(diab_year,style={"width":"100%"},id='diabetes_hist_year',value=2019),
dcc.Graph(
id='diabetes_hist',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("obesity.md",header = "Obesity"),
dcc.Dropdown(questions,style={"width":"100%"},id='obesity_line_state_drop',value="Alabama"),
dcc.Graph(
id='obesity_line',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("sdoh_conclusion.md",header = "Social Determinant Trends Hold True"),
cdc.explanation_component("alcohol.md",header = "Alcohol Consumption"),
dcc.Dropdown(alc_ques,style={"width":"100%"},id='alc_scat_qeust',value="Binge drinking intensity among adults who binge drink"),
dcc.Dropdown(alc_year,style={"width":"100%"},id='alc_scat_year',value=2019),
dcc.Dropdown(alc_metric,style={"width":"100%"},id='alc_scat_metric',value="Crude Median"),
dcc.Graph(
id='alc_scat',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("smoke.md",header = "Smoking"),
dcc.Dropdown(smoke_ques,style={"width":"100%"},id='smoke_scat_qeust',value="Quit attempts in the past year among adult current smokers"),
dcc.Dropdown(smoke_year,style={"width":"100%"},id='smoke_scat_year',value=2019),
dcc.Dropdown(smoke_metric,style={"width":"100%"},id='smoke_scat_metric',value="Crude Prevalence"),
dcc.Graph(
id='smoke_scat',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("depression.md",header = "Mental Health"),
dcc.Dropdown(stress_ques,style={"width":"100%"},id='stress_scat_qeust',value="Depression among adults"),
dcc.Dropdown(stress_year,style={"width":"100%"},id='stress_scat_year',value=2019),
dcc.Dropdown(stress_metric,style={"width":"100%"},id='stress_scat_metric',value="Crude Prevalence"),
dcc.Graph(
id='stress_scat',
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("eda_n.md",header = "Life Expectancy Predictors"),
dcc.Graph(
id='life_sleep',
figure = eda_plots.coorelation(),
style={
"width":"100%",
"height":"70vh",
}
),
cdc.explanation_component("ml.md",header = "Machine Learning Prediction"),
html.Label('percentage of population that is obese',style={"color":"#DBF7EC"}),
dcc.Input(value=50, type='number',id="ml_ob"),
html.Label('percentage of population that smokes',style={"color":"#DBF7EC"}),
dcc.Input(value=50, type='number',id="ml_smoke"),
html.Label('percentage of population that doesn\'t get enough sleep',style={"color":"#DBF7EC"}),
dcc.Input(value=50, type='number',id="ml_sleep"),
html.P("The life expectancy for your population is:",style={"color":"#DBF7EC"}),
html.Div(id="ml_predict",style={"color":"#DBF7EC"})
],
style={
"width":"100vw",
"display":"flex",
"align-items":"center",
"flex-direction":"column",
"padding":"0 6em",
"box-sizing":'border-box',
"background-color":"#1C506C"
})
if __name__ == '__main__':
app.run_server(debug=False, port=8080)