Rathapoom commited on
Commit
72737ba
·
verified ·
1 Parent(s): 0a7b76b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -66,13 +66,13 @@ def display_prediction_tables_and_plots(prediction_tables, baseline_bmd, baselin
66
  tscore_values = [baseline_tscore] + list(table['Predicted T-score'])
67
 
68
  # Create BMD plot
69
- trace_bmd = go.Scatter(x=years, y=bmd_values, mode='lines+markers', name=f'{drug} (BMD)')
70
  fig_bmd = go.Figure(data=[trace_bmd], layout=go.Layout(title=f'{drug} - Predicted BMD over Time', xaxis=dict(title='Years'), yaxis=dict(title='BMD (g/cm²)')))
71
 
72
  # Create T-score plot
73
- trace_tscore = go.Scatter(x=years, y=tscore_values, mode='lines+markers', name=f'{drug} (T-score)', yaxis='y2')
74
- fig_tscore = go.Figure(data=[trace_tscore], layout=go.Layout(title=f'{drug} - Predicted T-score over Time', xaxis=dict(title='Years'), yaxis2=dict(title='T-score', overlaying='y', side='right')))
75
-
76
  # Display the plots
77
  col1, col2 = st.columns(2)
78
  with col1:
@@ -80,6 +80,16 @@ def display_prediction_tables_and_plots(prediction_tables, baseline_bmd, baselin
80
  with col2:
81
  st.plotly_chart(fig_tscore)
82
 
 
 
 
 
 
 
 
 
 
 
83
  # Step 6: Calculate T-score from adjusted BMD
84
  def calculate_tscore_from_bmd(bmd_patient, c_avg, c_sd):
85
  return (bmd_patient - c_avg) / c_sd
 
66
  tscore_values = [baseline_tscore] + list(table['Predicted T-score'])
67
 
68
  # Create BMD plot
69
+ trace_bmd = go.Scatter(x=years, y=bmd_values, mode='lines+markers', name=f'{drug} (BMD)', line=dict(color='blue'))
70
  fig_bmd = go.Figure(data=[trace_bmd], layout=go.Layout(title=f'{drug} - Predicted BMD over Time', xaxis=dict(title='Years'), yaxis=dict(title='BMD (g/cm²)')))
71
 
72
  # Create T-score plot
73
+ trace_tscore = go.Scatter(x=years, y=tscore_values, mode='lines+markers', name=f'{drug} (T-score)', line=dict(color='green'))
74
+ fig_tscore = go.Figure(data=[trace_tscore], layout=go.Layout(title=f'{drug} - Predicted T-score over Time', xaxis=dict(title='Years'), yaxis=dict(title='T-score')))
75
+
76
  # Display the plots
77
  col1, col2 = st.columns(2)
78
  with col1:
 
80
  with col2:
81
  st.plotly_chart(fig_tscore)
82
 
83
+ # Step 6: Check if goal is achieved and show the predicted BMD and T-score for each year
84
+ goal_achieved = False
85
+ for i, row in table.iterrows():
86
+ if row['Predicted T-score'] >= -2.49:
87
+ st.success(f"Goal achieved for {drug} at year {row['Year']} with T-score = {row['Predicted T-score']:.2f}")
88
+ goal_achieved = True
89
+ break
90
+ if not goal_achieved:
91
+ st.warning(f"Goal not achieved for {drug}")
92
+
93
  # Step 6: Calculate T-score from adjusted BMD
94
  def calculate_tscore_from_bmd(bmd_patient, c_avg, c_sd):
95
  return (bmd_patient - c_avg) / c_sd