Rathapoom commited on
Commit
d0ee391
·
verified ·
1 Parent(s): cf4318d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -91,7 +91,35 @@ def display_results(predictions, site):
91
  xaxis=dict(tickmode='array', tickvals=predictions['Year Index'], ticktext=predictions['Year'])
92
  )))
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  # Streamlit UI
 
95
  def main():
96
  st.title("BMD and T-score Prediction Tool")
97
 
@@ -159,6 +187,11 @@ def main():
159
  if not filtered_predictions:
160
  st.warning("No medications selected. Please select at least one medication or use the 'Show All' option.")
161
  else:
 
 
 
 
 
162
  display_results(filtered_predictions, selected_site)
163
 
164
  if __name__ == "__main__":
 
91
  xaxis=dict(tickmode='array', tickvals=predictions['Year Index'], ticktext=predictions['Year'])
92
  )))
93
 
94
+ # Generate summary of medications reaching the target BMD
95
+ def generate_goal_summary(predictions, target_bmd=2.4):
96
+ goal_reached = []
97
+
98
+ for result in predictions:
99
+ drug = result['Drug']
100
+ predictions_data = result['Predictions']
101
+
102
+ for year, bmd in zip(predictions_data['Year'], predictions_data['Predicted BMD']):
103
+ if bmd >= target_bmd:
104
+ goal_reached.append({'Medication': drug, 'Year': int(year)})
105
+ break # Stop checking further years for this drug
106
+
107
+ # Sort by year to prioritize earlier achievement
108
+ goal_reached_sorted = sorted(goal_reached, key=lambda x: x['Year'])
109
+ return goal_reached_sorted
110
+
111
+ # Display summary of goal-reaching medications
112
+ def display_goal_summary(goal_summary):
113
+ st.subheader("Goal Treatment Summary (BMD ≥ 2.4)")
114
+
115
+ if not goal_summary:
116
+ st.info("No medications reach the target BMD.")
117
+ else:
118
+ summary_table = pd.DataFrame(goal_summary)
119
+ st.table(summary_table)
120
+
121
  # Streamlit UI
122
+ # Main function
123
  def main():
124
  st.title("BMD and T-score Prediction Tool")
125
 
 
187
  if not filtered_predictions:
188
  st.warning("No medications selected. Please select at least one medication or use the 'Show All' option.")
189
  else:
190
+ # Generate and display goal treatment summary
191
+ goal_summary = generate_goal_summary(filtered_predictions, target_bmd=2.4)
192
+ display_goal_summary(goal_summary)
193
+
194
+ # Display individual medication results
195
  display_results(filtered_predictions, selected_site)
196
 
197
  if __name__ == "__main__":