DOMMETI commited on
Commit
c85eece
·
verified ·
1 Parent(s): 1502f2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import pandas as pd
3
  import numpy as np
 
4
  st.markdown("""
5
  <style>
6
  /* Set a soft background color */
@@ -80,3 +81,41 @@ st.markdown("""
80
  <li>Analysis</li>
81
  <li>Structuring</li>
82
  </ul>""",unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import pandas as pd
3
  import numpy as np
4
+ import matplotlib.pyplot as plt
5
  st.markdown("""
6
  <style>
7
  /* Set a soft background color */
 
81
  <li>Analysis</li>
82
  <li>Structuring</li>
83
  </ul>""",unsafe_allow_html=True)
84
+ st.title("Drug Trial Analysis")
85
+
86
+ # Input for number of participants
87
+ total_participants = st.number_input("Total Participants:", min_value=100, max_value=10000, value=1000)
88
+
89
+ # Input for number of participants in drug and placebo groups
90
+ drug_group_size = st.number_input("Size of Drug Group:", min_value=1, max_value=total_participants - 1, value=500)
91
+ placebo_group_size = total_participants - drug_group_size
92
+
93
+ # Input for side effects
94
+ side_effects_drug = st.number_input("Number of Side Effects in Drug Group:", min_value=0, max_value=drug_group_size, value=100)
95
+ side_effects_placebo = st.number_input("Number of Side Effects in Placebo Group:", min_value=0, max_value=placebo_group_size, value=20)
96
+
97
+ # Calculate probabilities
98
+ p_side_effects_drug = side_effects_drug / drug_group_size
99
+ p_side_effects_placebo = side_effects_placebo / placebo_group_size
100
+
101
+ # Calculate Risk Difference and Relative Risk
102
+ risk_difference = p_side_effects_drug - p_side_effects_placebo
103
+ relative_risk = p_side_effects_drug / p_side_effects_placebo if p_side_effects_placebo > 0 else np.nan
104
+
105
+ # Display results
106
+ st.subheader("Results:")
107
+ st.write(f"Probability of Side Effects in Drug Group: {p_side_effects_drug:.2%}")
108
+ st.write(f"Probability of Side Effects in Placebo Group: {p_side_effects_placebo:.2%}")
109
+ st.write(f"Risk Difference: {risk_difference:.2%}")
110
+ st.write(f"Relative Risk: {relative_risk:.2f}" if not np.isnan(relative_risk) else "Relative Risk: Undefined (Placebo group has no side effects)")
111
+
112
+ # Visualization
113
+ st.subheader("Visualization")
114
+ labels = ['Drug Group', 'Placebo Group']
115
+ sizes = [p_side_effects_drug, p_side_effects_placebo]
116
+ colors = ['lightblue', 'lightgreen']
117
+
118
+ fig, ax = plt.subplots()
119
+ ax.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=90)
120
+ ax.axis('equal') # Equal aspect ratio ensures that pie chart is circular.
121
+ st.pyplot(fig)