Rathapoom commited on
Commit
094d1d2
·
verified ·
1 Parent(s): 9ab38ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -93,6 +93,13 @@ def display_results(predictions, site):
93
 
94
  # Generate summary of medications reaching the target T-score
95
  def generate_goal_summary(predictions, target_tscore=-2.4):
 
 
 
 
 
 
 
96
  goal_reached = []
97
 
98
  for result in predictions:
@@ -100,8 +107,10 @@ def generate_goal_summary(predictions, target_tscore=-2.4):
100
  predictions_data = result['Predictions']
101
 
102
  for year, tscore in zip(predictions_data['Year'], predictions_data['Predicted T-score']):
103
- if tscore >= target_tscore: # Check against Predicted T-score
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
 
93
 
94
  # Generate summary of medications reaching the target T-score
95
  def generate_goal_summary(predictions, target_tscore=-2.4):
96
+ def year_to_int(year):
97
+ # Convert "1st", "2nd", "3rd", etc., to numeric values
98
+ try:
99
+ return int(year.rstrip("stndrdth")) # Remove suffixes like "st", "nd", "rd", "th"
100
+ except ValueError:
101
+ return 0 # Default to 0 if year cannot be converted
102
+
103
  goal_reached = []
104
 
105
  for result in predictions:
 
107
  predictions_data = result['Predictions']
108
 
109
  for year, tscore in zip(predictions_data['Year'], predictions_data['Predicted T-score']):
110
+ if tscore >= target_tscore:
111
+ # Convert year to an integer using helper function
112
+ numeric_year = year_to_int(year)
113
+ goal_reached.append({'Medication': drug, 'Year': numeric_year})
114
  break # Stop checking further years for this drug
115
 
116
  # Sort by year to prioritize earlier achievement