Kwang517 commited on
Commit
6158220
1 Parent(s): 383ca98

Update app (3).py

Browse files
Files changed (1) hide show
  1. app (3).py +31 -5
app (3).py CHANGED
@@ -171,11 +171,37 @@ elif app_mode == '02 Visualization':
171
  st.pyplot(fig)
172
 
173
  st.subheader("FCVC : Do you usually eat vegetables in your meals?")
174
- crosstab = pd.crosstab(df['FAVC'], df['OL'])
175
- fig, ax = plt.subplots()
176
- crosstab.plot(kind='bar',width=0.8, ax=ax)
177
- for p in ax.patches:
178
- ax.annotate(str(p.get_height()), (p.get_x() * 1.005, p.get_height() * 1.005))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  st.pyplot(fig)
180
 
181
  elif varibles=='PHYSICAL ACTIVITY':
 
171
  st.pyplot(fig)
172
 
173
  st.subheader("FCVC : Do you usually eat vegetables in your meals?")
174
+ df_ot = df[df["OL"] == 'Obesity_Type_I' ]
175
+ df_ot2 = df[df["OL"] == 'Obesity_Type_II']
176
+ df_ot3 = df[df["OL"] == 'Obesity_Type_III']
177
+
178
+ df_ot_final = pd.concat([df_ot,df_ot2,df_ot3]) # data frem of Obesity_Type I, II, III
179
+ df_ot_final.reset_index(drop=True, inplace = True)
180
+
181
+ df_ow = df[df["OL"]=='Overweight_Level_I']
182
+ df_ow2 = df[df["OL"]=='Overweight_Level_II']
183
+
184
+ df_ow_final = pd.concat([df_ow,df_ow2]) # data frem of Over_weight_Type I, II
185
+ df_ow_final.reset_index(drop=True, inplace = True)
186
+
187
+ df_n = df[df["OL"]=='Normal_Weight']
188
+
189
+ df_In = df[df["OL"]=='Insufficient_Weight']
190
+
191
+ data_list = [df_ot_final, df_ow_final, df_n, df_In]
192
+ data_name = ["obesity_type", "over_weight_type", "normal", "Insufficient_Weight"]
193
+
194
+ fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(10,8))
195
+
196
+ for i in range(2):
197
+ sns.kdeplot(ax=axes[i,0], data=data_list[i], x="FCVC", hue="OL", fill=True)
198
+ axes[i, 0].set_title(f'{data_name[i]} vs FCVC')
199
+
200
+ sns.kdeplot(ax=axes[i,1], data=data_list[i+2], x="FCVC", hue="OL", fill=True)
201
+ axes[i, 1].set_title(f'{data_name[i+2]} vs FCVC')
202
+
203
+ fig.suptitle('Obesity_levels vs FCVC')
204
+ plt.tight_layout()
205
  st.pyplot(fig)
206
 
207
  elif varibles=='PHYSICAL ACTIVITY':