DIVYANSHI SINGH commited on
Commit
4fac588
·
1 Parent(s): 6ac4e5b

Layout Fix: Switched to Centered layout and 100% column-free Overview for total stability

Browse files
Files changed (1) hide show
  1. app.py +20 -26
app.py CHANGED
@@ -21,8 +21,8 @@ SEGMENT_PRODUCTS_PATH = os.path.join(BASE_DIR, "outputs", "segment_products.csv"
21
  st.set_page_config(
22
  page_title="SegmentX: Customer Intelligence",
23
  page_icon="🛍️",
24
- layout="wide",
25
- initial_sidebar_state="expanded"
26
  )
27
 
28
  # Custom Styling
@@ -37,22 +37,18 @@ st.markdown("""
37
  padding: 24px;
38
  border-radius: 12px;
39
  border: 1px solid #374151;
40
- margin-bottom: 10px;
41
  }
42
  h1, h2, h3 {
43
  color: #60a5fa;
44
  font-family: 'Inter', sans-serif;
45
  }
46
- .block-container {
47
- padding: 2rem 10% 5rem 10%;
48
- }
49
- /* Simple Info Box */
50
  .info-box {
51
  background-color: rgba(96, 165, 250, 0.1);
52
  padding: 20px;
53
  border-radius: 15px;
54
  border-left: 6px solid #60a5fa;
55
- margin: 20px 0;
56
  }
57
  </style>
58
  """, unsafe_allow_html=True)
@@ -218,24 +214,22 @@ def main():
218
 
219
  st.markdown("---")
220
 
221
- # Extraordinary Feature: Export & Churn Insights
222
- e1, e2 = st.columns(2)
223
- with e1:
224
- st.subheader("📥 Export Segment List")
225
- st.write(f"Download the list of **{len(df_filtered)}** customers in the selected segments for your next email campaign.")
226
- csv = df_filtered.to_csv().encode('utf-8')
227
- st.download_button("Download CSV", data=csv, file_name='customer_segments_export.csv', mime='text/csv')
228
-
229
- with e2:
230
- st.subheader("🚨 Behavioral Analytics")
231
- # Predictive Churn Insight: Aggregated for selection
232
- high_risk = len(df_filtered[df_filtered['Recency'] > 90])
233
- risk_pct = (high_risk / len(df_filtered)) * 100
234
- st.write(f"**Selection Overview**: {risk_pct:.1f}% Customers are beyond a 90-day purchase gap.")
235
- if risk_pct > 30:
236
- st.warning("⚠️ High overall churn risk detected in selected segments.")
237
- else:
238
- st.success("✅ Healthy retention rate for these segments.")
239
 
240
  elif page == "Segment Profiles":
241
  st.subheader("Cluster Behavioral Profiles")
 
21
  st.set_page_config(
22
  page_title="SegmentX: Customer Intelligence",
23
  page_icon="🛍️",
24
+ layout="centered",
25
+ initial_sidebar_state="auto"
26
  )
27
 
28
  # Custom Styling
 
37
  padding: 24px;
38
  border-radius: 12px;
39
  border: 1px solid #374151;
40
+ margin-bottom: 20px;
41
  }
42
  h1, h2, h3 {
43
  color: #60a5fa;
44
  font-family: 'Inter', sans-serif;
45
  }
46
+ /* Minimalist Info Box */
 
 
 
47
  .info-box {
48
  background-color: rgba(96, 165, 250, 0.1);
49
  padding: 20px;
50
  border-radius: 15px;
51
  border-left: 6px solid #60a5fa;
 
52
  }
53
  </style>
54
  """, unsafe_allow_html=True)
 
214
 
215
  st.markdown("---")
216
 
217
+ # Extraordinary Feature: Export & Churn Insights - Absolute Vertical Stability
218
+ st.subheader("📥 Export Segment List")
219
+ st.write(f"Download the list of **{len(df_filtered)}** customers in the selected segments for your next email campaign.")
220
+ csv = df_filtered.to_csv().encode('utf-8')
221
+ st.download_button("Download CSV", data=csv, file_name='customer_segments_export.csv', mime='text/csv')
222
+
223
+ st.markdown("<br>", unsafe_allow_html=True)
224
+ st.subheader("🚨 Behavioral Analytics")
225
+ # Predictive Churn Insight: Aggregated for selection
226
+ high_risk = len(df_filtered[df_filtered['Recency'] > 90])
227
+ risk_pct = (high_risk / len(df_filtered)) * 100
228
+ st.write(f"**Selection Overview**: {risk_pct:.1f}% Customers are beyond a 90-day purchase gap.")
229
+ if risk_pct > 30:
230
+ st.warning("⚠️ High overall churn risk detected in selected segments.")
231
+ else:
232
+ st.success(" Healthy retention rate for these segments.")
 
 
233
 
234
  elif page == "Segment Profiles":
235
  st.subheader("Cluster Behavioral Profiles")