Update app.py
Browse files
app.py
CHANGED
@@ -135,47 +135,26 @@ if st.button("🔮 Predict Sepsis"):
|
|
135 |
# Convert the input data to a pandas DataFrame
|
136 |
input_df = pd.DataFrame([input_data])
|
137 |
|
138 |
-
# Display DataFrame
|
139 |
st.table(input_df)
|
140 |
|
141 |
-
# Download Button
|
142 |
-
|
143 |
-
|
144 |
-
if
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
label="Download Excel",
|
159 |
-
data=excel_file,
|
160 |
-
file_name=f"sepsis_prediction_{patient_name}.xlsx",
|
161 |
-
key='excel-download',
|
162 |
-
)
|
163 |
-
|
164 |
-
# Export to PDF
|
165 |
-
pdf_file = BytesIO()
|
166 |
-
pdf_canvas = canvas.Canvas(pdf_file)
|
167 |
-
pdf_canvas.drawString(100, 800, heading)
|
168 |
-
table = input_df.to_string().split('\n')
|
169 |
-
pdf_canvas.drawString(100, 780, '\n'.join(table))
|
170 |
-
pdf_canvas.save()
|
171 |
-
pdf_file.seek(0)
|
172 |
-
st.download_button(
|
173 |
-
label="Download PDF",
|
174 |
-
data=pdf_file,
|
175 |
-
file_name=f"sepsis_prediction_{patient_name}.pdf",
|
176 |
-
key='pdf-download',
|
177 |
-
)
|
178 |
-
|
179 |
except Exception as e:
|
180 |
st.error(f"An error occurred: {e}")
|
181 |
|
|
|
135 |
# Convert the input data to a pandas DataFrame
|
136 |
input_df = pd.DataFrame([input_data])
|
137 |
|
138 |
+
# Display the DataFrame
|
139 |
st.table(input_df)
|
140 |
|
141 |
+
# Download Button Section
|
142 |
+
st.subheader("Download Prediction")
|
143 |
+
patient_name = st.text_input("Enter the patient's name:")
|
144 |
+
if st.button("Download Prediction"):
|
145 |
+
if patient_name:
|
146 |
+
# Generate the heading
|
147 |
+
heading = f"Sepsis Status Prediction For {patient_name}"
|
148 |
+
|
149 |
+
# Save the DataFrame to a CSV file
|
150 |
+
input_df.to_csv(f"{patient_name}_sepsis_prediction.csv", index=False, encoding='utf-8-sig')
|
151 |
+
|
152 |
+
# Provide a download link
|
153 |
+
st.markdown(f"### [Download {patient_name}'s Prediction CSV](data:{patient_name}_sepsis_prediction.csv)")
|
154 |
+
|
155 |
+
else:
|
156 |
+
st.warning("Please enter the patient's name.")
|
157 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
except Exception as e:
|
159 |
st.error(f"An error occurred: {e}")
|
160 |
|