BiswajitPadhi99 commited on
Commit
dc05443
·
1 Parent(s): fcebbb6

Modify app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -16
app.py CHANGED
@@ -292,9 +292,9 @@ st.sidebar.header("Filter Data")
292
 
293
  @st.cache_data
294
  def load_data():
295
- # Load the dataframes (update the paths as necessary)
296
  admissions_df = pd.read_feather('data/admissions.feather')
297
- patients_df = pd.read_featehr('data/patients.feather')
298
  # diagnoses_icd_df = pd.read_csv('data/diagnoses_icd.csv')
299
  pharmacy_df = pd.read_feather('data/pharmacy.feather')
300
  # prescriptions_df = pd.read_csv('data/prescriptions.csv')
@@ -346,7 +346,7 @@ def load_data():
346
  # Convert datetime columns
347
  merged_df['admittime'] = pd.to_datetime(merged_df['admittime'])
348
  merged_df['dischtime'] = pd.to_datetime(merged_df['dischtime'])
349
- merged_df['deathtime'] = pd.to_datetime(merged_df['deathtime'], errors='coerce') # Some may not have deathtime
350
 
351
  # Create derived features
352
  merged_df['los'] = (merged_df['dischtime'] - merged_df['admittime']).dt.days
@@ -419,7 +419,6 @@ filtered_df = add_sidebar_filters(merged_df)
419
  # Display Summary Statistics for Q1
420
  st.header("Summary Statistics")
421
 
422
- # Create four columns for metrics
423
  col1, col2, col3, col4 = st.columns(4)
424
 
425
  with col1:
@@ -446,16 +445,12 @@ st.markdown("---")
446
  # Create Tabs for Q1 and Q2
447
  tabs = st.tabs(["General Overview", "Potential Biases"])
448
 
449
- # ---------------------------
450
  # Q1: General Overview
451
- # ---------------------------
452
  with tabs[0]:
453
  st.subheader("General Feature Distribution and Outcome Metrics")
454
 
455
- # Define the number of columns per row
456
  num_cols = 2
457
 
458
- # Define all Q1 plots in a list with titles and plot-generating functions
459
  q1_plots = [
460
  {
461
  "title": "Age Distribution of ICU Patients",
@@ -482,8 +477,7 @@ with tabs[0]:
482
  "plot": lambda: create_time_series_heatmap(filtered_df)
483
  }
484
  ]
485
-
486
- # Arrange Q1 plots in a grid layout
487
  for i in range(0, len(q1_plots), num_cols):
488
  cols = st.columns(num_cols)
489
  for j in range(num_cols):
@@ -492,16 +486,13 @@ with tabs[0]:
492
  st.subheader(q1_plots[i + j]["title"])
493
  q1_plots[i + j]["plot"]()
494
 
495
- # ---------------------------
496
- # Q2: Potential Biases
497
- # ---------------------------
498
  with tabs[1]:
499
  st.subheader("Analyzing Potential Biases Across Demographics")
500
 
501
- # Define the number of columns per row
502
  num_cols = 2
503
 
504
- # Define all Q2 plots in a list with titles and plot-generating functions
505
  q2_plots = [
506
  {
507
  "title": "Mortality Rate by Race",
@@ -537,7 +528,6 @@ with tabs[1]:
537
  }
538
  ]
539
 
540
- # Arrange Q2 plots in a grid layout
541
  for i in range(0, len(q2_plots), num_cols):
542
  cols = st.columns(num_cols)
543
  for j in range(num_cols):
 
292
 
293
  @st.cache_data
294
  def load_data():
295
+
296
  admissions_df = pd.read_feather('data/admissions.feather')
297
+ patients_df = pd.read_feather('data/patients.feather')
298
  # diagnoses_icd_df = pd.read_csv('data/diagnoses_icd.csv')
299
  pharmacy_df = pd.read_feather('data/pharmacy.feather')
300
  # prescriptions_df = pd.read_csv('data/prescriptions.csv')
 
346
  # Convert datetime columns
347
  merged_df['admittime'] = pd.to_datetime(merged_df['admittime'])
348
  merged_df['dischtime'] = pd.to_datetime(merged_df['dischtime'])
349
+ merged_df['deathtime'] = pd.to_datetime(merged_df['deathtime'], errors='coerce')
350
 
351
  # Create derived features
352
  merged_df['los'] = (merged_df['dischtime'] - merged_df['admittime']).dt.days
 
419
  # Display Summary Statistics for Q1
420
  st.header("Summary Statistics")
421
 
 
422
  col1, col2, col3, col4 = st.columns(4)
423
 
424
  with col1:
 
445
  # Create Tabs for Q1 and Q2
446
  tabs = st.tabs(["General Overview", "Potential Biases"])
447
 
 
448
  # Q1: General Overview
 
449
  with tabs[0]:
450
  st.subheader("General Feature Distribution and Outcome Metrics")
451
 
 
452
  num_cols = 2
453
 
 
454
  q1_plots = [
455
  {
456
  "title": "Age Distribution of ICU Patients",
 
477
  "plot": lambda: create_time_series_heatmap(filtered_df)
478
  }
479
  ]
480
+
 
481
  for i in range(0, len(q1_plots), num_cols):
482
  cols = st.columns(num_cols)
483
  for j in range(num_cols):
 
486
  st.subheader(q1_plots[i + j]["title"])
487
  q1_plots[i + j]["plot"]()
488
 
489
+
490
+ # Q2: Potential Biases from patient side
 
491
  with tabs[1]:
492
  st.subheader("Analyzing Potential Biases Across Demographics")
493
 
 
494
  num_cols = 2
495
 
 
496
  q2_plots = [
497
  {
498
  "title": "Mortality Rate by Race",
 
528
  }
529
  ]
530
 
 
531
  for i in range(0, len(q2_plots), num_cols):
532
  cols = st.columns(num_cols)
533
  for j in range(num_cols):