Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,19 @@ import pickle
|
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Load the model and key components
|
| 7 |
with open('model_and_key_components.pkl', 'rb') as file:
|
| 8 |
loaded_components = pickle.load(file)
|
|
@@ -22,11 +35,12 @@ data_fields = {
|
|
| 22 |
"Age": "Age of the patient (years)"
|
| 23 |
}
|
| 24 |
|
| 25 |
-
# Page Title
|
| 26 |
-
st.title("Sepsis Prediction App")
|
|
|
|
| 27 |
|
| 28 |
# Sidebar with Data Fields
|
| 29 |
-
st.sidebar.title("Input Data")
|
| 30 |
input_data = {}
|
| 31 |
for field, description in data_fields.items():
|
| 32 |
input_data[field] = st.sidebar.number_input(description, value=0.0)
|
|
@@ -43,8 +57,8 @@ def make_predictions(input_data_scaled_df):
|
|
| 43 |
sepsis_mapping = {0: 'Negative', 1: 'Positive'}
|
| 44 |
return sepsis_mapping[y_pred[0]]
|
| 45 |
|
| 46 |
-
# Predict Button
|
| 47 |
-
if st.sidebar.button("Predict Sepsis"):
|
| 48 |
try:
|
| 49 |
input_data_scaled_df = preprocess_input_data(input_data)
|
| 50 |
sepsis_status = make_predictions(input_data_scaled_df)
|
|
@@ -53,19 +67,6 @@ if st.sidebar.button("Predict Sepsis"):
|
|
| 53 |
st.error(f"An error occurred: {e}")
|
| 54 |
|
| 55 |
# Display Data Fields and Descriptions
|
| 56 |
-
st.sidebar.title("Data Fields")
|
| 57 |
for field, description in data_fields.items():
|
| 58 |
st.sidebar.text(f"{field}: {description}")
|
| 59 |
-
|
| 60 |
-
# About Section
|
| 61 |
-
st.sidebar.title("About")
|
| 62 |
-
st.sidebar.info(
|
| 63 |
-
"This app predicts sepsis based on medical input data. "
|
| 64 |
-
"It uses a machine learning model trained on a dataset of sepsis cases."
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
-
# Welcome Message
|
| 68 |
-
st.write(
|
| 69 |
-
"Welcome to the Sepsis Prediction App! Enter the medical data in the sidebar, "
|
| 70 |
-
"click 'Predict Sepsis', and get the prediction result."
|
| 71 |
-
)
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
|
| 6 |
+
# About Section with Style
|
| 7 |
+
st.sidebar.title("ℹ️ About")
|
| 8 |
+
st.sidebar.info(
|
| 9 |
+
"This app predicts sepsis based on medical input data. "
|
| 10 |
+
"It uses a machine learning model trained on a dataset of sepsis cases."
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
# Welcome Message with Style
|
| 14 |
+
st.write(
|
| 15 |
+
"👋 Welcome to the Sepsis Prediction App! Enter the medical data in the sidebar, "
|
| 16 |
+
"click 'Predict Sepsis', and get the prediction result."
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
# Load the model and key components
|
| 20 |
with open('model_and_key_components.pkl', 'rb') as file:
|
| 21 |
loaded_components = pickle.load(file)
|
|
|
|
| 35 |
"Age": "Age of the patient (years)"
|
| 36 |
}
|
| 37 |
|
| 38 |
+
# Page Title with Style
|
| 39 |
+
st.title("🩸 Sepsis Prediction App")
|
| 40 |
+
st.markdown("---")
|
| 41 |
|
| 42 |
# Sidebar with Data Fields
|
| 43 |
+
st.sidebar.title("📊 Input Data")
|
| 44 |
input_data = {}
|
| 45 |
for field, description in data_fields.items():
|
| 46 |
input_data[field] = st.sidebar.number_input(description, value=0.0)
|
|
|
|
| 57 |
sepsis_mapping = {0: 'Negative', 1: 'Positive'}
|
| 58 |
return sepsis_mapping[y_pred[0]]
|
| 59 |
|
| 60 |
+
# Predict Button with Style
|
| 61 |
+
if st.sidebar.button("🔮 Predict Sepsis"):
|
| 62 |
try:
|
| 63 |
input_data_scaled_df = preprocess_input_data(input_data)
|
| 64 |
sepsis_status = make_predictions(input_data_scaled_df)
|
|
|
|
| 67 |
st.error(f"An error occurred: {e}")
|
| 68 |
|
| 69 |
# Display Data Fields and Descriptions
|
| 70 |
+
st.sidebar.title("🔍 Data Fields")
|
| 71 |
for field, description in data_fields.items():
|
| 72 |
st.sidebar.text(f"{field}: {description}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|