Rathapoom commited on
Commit
0943560
·
verified ·
1 Parent(s): 95b7274

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -34,22 +34,21 @@ def generate_predictions(medication_data, site, bmd, mu, sigma):
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
- baseline_bmd = bmd
38
  for year in row.index[1:-1]: # Skip 'Medication' and 'Site' columns
39
  if not pd.isna(row[year]):
40
  percentage_increase = row[year]
41
- predicted_bmd = calculate_bmd(baseline_bmd, percentage_increase)
 
42
  predicted_tscore = calculate_tscore(predicted_bmd, mu, sigma)
43
 
44
  predictions['Year'].append(year.replace(" Year", "")) # Simplify year label
45
  predictions['Predicted BMD'].append(round(predicted_bmd, 3))
46
  predictions['Predicted T-score'].append(round(predicted_tscore, 1))
47
-
48
- baseline_bmd = predicted_bmd
49
 
50
  all_results.append({'Drug': drug, 'Predictions': predictions})
51
  return all_results
52
 
 
53
  # Display results as table and plots
54
  def display_results(predictions, site):
55
  st.subheader(f"Predictions for {site}")
 
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
+ # BMD calculated using initial BMD (from user input)
41
+ predicted_bmd = bmd * (1 + percentage_increase / 100)
42
  predicted_tscore = calculate_tscore(predicted_bmd, mu, sigma)
43
 
44
  predictions['Year'].append(year.replace(" Year", "")) # Simplify year label
45
  predictions['Predicted BMD'].append(round(predicted_bmd, 3))
46
  predictions['Predicted T-score'].append(round(predicted_tscore, 1))
 
 
47
 
48
  all_results.append({'Drug': drug, 'Predictions': predictions})
49
  return all_results
50
 
51
+
52
  # Display results as table and plots
53
  def display_results(predictions, site):
54
  st.subheader(f"Predictions for {site}")