DasariHarshitha commited on
Commit
a143d36
·
verified ·
1 Parent(s): 914b4b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -26
app.py CHANGED
@@ -54,12 +54,11 @@ if page == "Overview":
54
  - Simple, real-time capable models
55
  """)
56
 
57
- # ----------- EDA Page ------------
58
  elif page == "EDA":
59
  st.header(" Exploratory Data Analysis")
60
  df = load_data("cleaned_sleep_data.csv")
61
 
62
- # ---- Multi-select Filter Sleep/Wake ----
63
  st.markdown("### 🔎 Filter by Sleep State")
64
  state_options = st.multiselect("Select sleep states to display", ["Sleep", "Wake-Up"], default=["Sleep", "Wake-Up"])
65
 
@@ -68,42 +67,51 @@ elif page == "EDA":
68
  selected_values = [filter_map[opt] for opt in state_options]
69
  df = df[df["sleep"].isin(selected_values)]
70
 
71
- # ---- Histograms ----
72
  col1, col2 = st.columns(2)
73
  with col1:
74
- st.subheader(" Anglez")
75
- plot_histogram(df, "anglez", "#74b9ff")
76
- st.markdown("- Distribution typical of rest posture")
 
 
 
77
 
78
  with col2:
79
- st.subheader(" ENMO")
80
- plot_histogram(df, "enmo", "#81ecec")
81
- st.markdown("- ENMO reflects movement intensity")
82
-
83
- # ---- Pairplot ----
84
- st.subheader(" Feature Relationships")
85
- with st.spinner("Creating pairplot..."):
86
- pairplot_fig = sns.pairplot(df, vars=['anglez', 'enmo'], hue='sleep', palette='coolwarm')
87
- st.pyplot(pairplot_fig.fig, use_container_width=True)
88
  plt.close()
89
 
90
- # ---- Boxplots ----
91
- st.subheader(" Boxplots")
92
  fig, axs = plt.subplots(1, 2, figsize=(12, 5))
93
- sns.boxplot(y=df["anglez"], ax=axs[0], color='#74b9ff')
94
- axs[0].set_title("Boxplot: Anglez")
95
- sns.boxplot(y=df["enmo"], ax=axs[1], color='#81ecec')
96
- axs[1].set_title("Boxplot: ENMO")
97
- st.pyplot(fig, use_container_width=True)
98
  plt.close()
99
 
100
- # ---- Correlation ----
101
- st.subheader(" Correlation Heatmap")
 
 
 
 
 
 
 
102
  fig, ax = plt.subplots()
103
- sns.heatmap(df[["anglez", "enmo"]].corr(), annot=True, cmap="coolwarm", ax=ax)
104
- st.pyplot(fig, use_container_width=True)
 
 
105
  plt.close()
106
 
 
107
  # ----------- Predict Page ------------
108
  elif page == "Predict":
109
  st.header(" Sleep Prediction")
 
54
  - Simple, real-time capable models
55
  """)
56
 
 
57
  elif page == "EDA":
58
  st.header(" Exploratory Data Analysis")
59
  df = load_data("cleaned_sleep_data.csv")
60
 
61
+ # ---- Filter by Sleep State ----
62
  st.markdown("### 🔎 Filter by Sleep State")
63
  state_options = st.multiselect("Select sleep states to display", ["Sleep", "Wake-Up"], default=["Sleep", "Wake-Up"])
64
 
 
67
  selected_values = [filter_map[opt] for opt in state_options]
68
  df = df[df["sleep"].isin(selected_values)]
69
 
70
+ # ---- KDE Plots ----
71
  col1, col2 = st.columns(2)
72
  with col1:
73
+ st.subheader("KDE Plot: Anglez")
74
+ fig, ax = plt.subplots()
75
+ sns.kdeplot(data=df, x="anglez", hue="sleep", fill=True, palette="magma", ax=ax)
76
+ ax.set_title("Sleep vs Wake - Anglez Distribution")
77
+ st.pyplot(fig)
78
+ plt.close()
79
 
80
  with col2:
81
+ st.subheader("KDE Plot: ENMO")
82
+ fig, ax = plt.subplots()
83
+ sns.kdeplot(data=df, x="enmo", hue="sleep", fill=True, palette="crest", ax=ax)
84
+ ax.set_title("Sleep vs Wake - ENMO Distribution")
85
+ st.pyplot(fig)
 
 
 
 
86
  plt.close()
87
 
88
+ # ---- Violin Plots ----
89
+ st.subheader("Violin Plots")
90
  fig, axs = plt.subplots(1, 2, figsize=(12, 5))
91
+ sns.violinplot(data=df, x="sleep", y="anglez", palette="Set2", ax=axs[0])
92
+ axs[0].set_title("Violin: Anglez")
93
+ sns.violinplot(data=df, x="sleep", y="enmo", palette="Set3", ax=axs[1])
94
+ axs[1].set_title("Violin: ENMO")
95
+ st.pyplot(fig)
96
  plt.close()
97
 
98
+ # ---- Joint Plot ----
99
+ st.subheader("Joint Distribution Plot")
100
+ with st.spinner("Generating jointplot..."):
101
+ joint = sns.jointplot(data=df, x="anglez", y="enmo", hue="sleep", kind="kde", fill=True, palette="viridis")
102
+ st.pyplot(joint.fig)
103
+ plt.close()
104
+
105
+ # ---- Correlation Heatmap ----
106
+ st.subheader("Correlation Heatmap")
107
  fig, ax = plt.subplots()
108
+ corr = df[["anglez", "enmo"]].corr()
109
+ sns.heatmap(corr, annot=True, fmt=".2f", cmap="coolwarm", square=True, linewidths=0.5, ax=ax)
110
+ ax.set_title("Feature Correlation")
111
+ st.pyplot(fig)
112
  plt.close()
113
 
114
+
115
  # ----------- Predict Page ------------
116
  elif page == "Predict":
117
  st.header(" Sleep Prediction")