Rathapoom commited on
Commit
7f5e310
·
verified ·
1 Parent(s): b93eca7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -16
app.py CHANGED
@@ -30,21 +30,13 @@ def generate_predictions(medication_data, site, bmd, mu, sigma):
30
  site_data = medication_data[medication_data['Site'] == site]
31
  all_results = []
32
 
33
- if site_data.empty:
34
- st.warning(f"No data available for the selected site: {site}")
35
- return all_results # Return empty results
36
-
37
  for _, row in site_data.iterrows():
38
  drug = row['Medication']
39
  predictions = {'Year': ['0'], 'Predicted BMD': [round(bmd, 3)], 'Predicted T-score': [round(calculate_tscore(bmd, mu, sigma), 1)]}
40
 
41
- st.write(f"Processing drug: {drug}")
42
-
43
  for year in row.index[1:-1]: # Skip 'Medication' and 'Site' columns
44
  if not pd.isna(row[year]):
45
  percentage_increase = row[year]
46
- st.write(f"Year: {year}, Percentage Increase: {percentage_increase}")
47
-
48
  predicted_bmd = bmd * (1 + percentage_increase)
49
  predicted_tscore = calculate_tscore(predicted_bmd, mu, sigma)
50
 
@@ -118,20 +110,13 @@ def main():
118
 
119
  # Load constants and medication data
120
  medication_data = load_medication_data()
121
- st.write("Loaded Medication Data:")
122
- st.write(medication_data.head()) # Display the loaded data for verification
123
-
124
  constants = REGRESSION_CONSTANTS.get(selected_site, {})
125
- if not constants:
126
- st.warning(f"No constants available for the selected site: {selected_site}")
127
- return
128
 
129
  # Generate and display predictions
130
  if st.button("Predict"):
131
- st.write("Prediction started...")
132
  predictions = generate_predictions(medication_data, site, bmd_patient, constants['mu'], constants['sigma'])
133
  display_results(predictions, selected_site)
134
 
135
-
136
  if __name__ == "__main__":
137
  main()
 
 
30
  site_data = medication_data[medication_data['Site'] == site]
31
  all_results = []
32
 
 
 
 
 
33
  for _, row in site_data.iterrows():
34
  drug = row['Medication']
35
  predictions = {'Year': ['0'], 'Predicted BMD': [round(bmd, 3)], 'Predicted T-score': [round(calculate_tscore(bmd, mu, sigma), 1)]}
36
 
 
 
37
  for year in row.index[1:-1]: # Skip 'Medication' and 'Site' columns
38
  if not pd.isna(row[year]):
39
  percentage_increase = row[year]
 
 
40
  predicted_bmd = bmd * (1 + percentage_increase)
41
  predicted_tscore = calculate_tscore(predicted_bmd, mu, sigma)
42
 
 
110
 
111
  # Load constants and medication data
112
  medication_data = load_medication_data()
 
 
 
113
  constants = REGRESSION_CONSTANTS.get(selected_site, {})
 
 
 
114
 
115
  # Generate and display predictions
116
  if st.button("Predict"):
 
117
  predictions = generate_predictions(medication_data, site, bmd_patient, constants['mu'], constants['sigma'])
118
  display_results(predictions, selected_site)
119
 
 
120
  if __name__ == "__main__":
121
  main()
122
+