Update app.py
Browse files
app.py
CHANGED
|
@@ -8,48 +8,34 @@ encoder = joblib.load("encoder_d.joblib")
|
|
| 8 |
scaler = joblib.load("scaler.joblib")
|
| 9 |
|
| 10 |
# Streamlit app
|
| 11 |
-
st.title("Diabetes Risk
|
| 12 |
st.write("Provide the following details to assess risk factors for diabetes.")
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
col1, col2, col3
|
|
|
|
| 16 |
with col1:
|
| 17 |
bmi = st.number_input("Body Mass Index (BMI):", min_value=10.0, max_value=50.0, step=0.1)
|
| 18 |
-
with col2:
|
| 19 |
family_history = st.selectbox("Family History of Diabetes:", options=encoder["Family_History"].classes_)
|
| 20 |
family_history = encoder["Family_History"].transform([family_history])[0]
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
physical_activity = st.selectbox("Physical Activity Level:", options=encoder["Physical_Activity"].classes_)
|
| 23 |
physical_activity = encoder["Physical_Activity"].transform([physical_activity])[0]
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
diet_type = st.selectbox("Diet Type:", options=encoder["Diet_Type"].classes_)
|
| 26 |
diet_type = encoder["Diet_Type"].transform([diet_type])[0]
|
| 27 |
-
with col5:
|
| 28 |
stress_level = st.selectbox("Stress Level:", options=encoder["Stress_Level"].classes_)
|
| 29 |
stress_level = encoder["Stress_Level"].transform([stress_level])[0]
|
| 30 |
-
|
| 31 |
-
# Row 2
|
| 32 |
-
col6, col7, col8, col9, col10 = st.columns(5)
|
| 33 |
-
with col6:
|
| 34 |
-
fasting_blood_sugar = st.number_input("Fasting Blood Sugar (mg/dL):", min_value=50, max_value=300, step=1)
|
| 35 |
-
with col7:
|
| 36 |
-
postprandial_blood_sugar = st.number_input("Postprandial Blood Sugar (mg/dL):", min_value=50, max_value=400, step=1)
|
| 37 |
-
with col8:
|
| 38 |
-
hba1c = st.number_input("HBA1C (%):", min_value=3.0, max_value=15.0, step=0.1)
|
| 39 |
-
with col9:
|
| 40 |
-
waist_hip_ratio = st.number_input("Waist-to-Hip Ratio:", min_value=0.5, max_value=2.0, step=0.01)
|
| 41 |
-
with col10:
|
| 42 |
glucose_tolerance = st.number_input("Glucose Tolerance Test Result (mg/dL):", min_value=50, max_value=300, step=1)
|
| 43 |
-
|
| 44 |
-
# Row 3
|
| 45 |
-
col11, col12, col13, col14 = st.columns(4)
|
| 46 |
-
with col11:
|
| 47 |
-
age = st.number_input("Age (years):", min_value=1, max_value=100, step=1)
|
| 48 |
-
with col12:
|
| 49 |
-
vitamin_d_level = st.number_input("Vitamin D Level (ng/mL):", min_value=5.0, max_value=100.0, step=0.1)
|
| 50 |
-
with col13:
|
| 51 |
c_protein_level = st.number_input("C-Reactive Protein Level (mg/L):", min_value=0.1, max_value=20.0, step=0.1)
|
| 52 |
-
with col14:
|
| 53 |
cholesterol_level = st.number_input("Cholesterol Level (mg/dL):", min_value=100, max_value=400, step=1)
|
| 54 |
|
| 55 |
# Collect input values into a list
|
|
@@ -59,10 +45,13 @@ values = [bmi, family_history, physical_activity, diet_type, stress_level, fasti
|
|
| 59 |
|
| 60 |
# Submit button
|
| 61 |
if st.button("Submit"):
|
|
|
|
| 62 |
values = scaler.transform([values])
|
| 63 |
prediction = model.predict(values)
|
| 64 |
|
|
|
|
| 65 |
if prediction == 1:
|
| 66 |
-
st.
|
| 67 |
else:
|
| 68 |
-
st.success("
|
|
|
|
|
|
| 8 |
scaler = joblib.load("scaler.joblib")
|
| 9 |
|
| 10 |
# Streamlit app
|
| 11 |
+
st.title("🔍 Smart Diabetes Risk Assessment System")
|
| 12 |
st.write("Provide the following details to assess risk factors for diabetes.")
|
| 13 |
|
| 14 |
+
# Create 3 columns
|
| 15 |
+
col1, col2, col3 = st.columns(3)
|
| 16 |
+
|
| 17 |
with col1:
|
| 18 |
bmi = st.number_input("Body Mass Index (BMI):", min_value=10.0, max_value=50.0, step=0.1)
|
|
|
|
| 19 |
family_history = st.selectbox("Family History of Diabetes:", options=encoder["Family_History"].classes_)
|
| 20 |
family_history = encoder["Family_History"].transform([family_history])[0]
|
| 21 |
+
fasting_blood_sugar = st.number_input("Fasting Blood Sugar (mg/dL):", min_value=50, max_value=300, step=1)
|
| 22 |
+
hba1c = st.number_input("HBA1C (%):", min_value=3.0, max_value=15.0, step=0.1)
|
| 23 |
+
age = st.number_input("Age (years):", min_value=1, max_value=100, step=1)
|
| 24 |
+
|
| 25 |
+
with col2:
|
| 26 |
physical_activity = st.selectbox("Physical Activity Level:", options=encoder["Physical_Activity"].classes_)
|
| 27 |
physical_activity = encoder["Physical_Activity"].transform([physical_activity])[0]
|
| 28 |
+
postprandial_blood_sugar = st.number_input("Postprandial Blood Sugar (mg/dL):", min_value=50, max_value=400, step=1)
|
| 29 |
+
waist_hip_ratio = st.number_input("Waist-to-Hip Ratio:", min_value=0.5, max_value=2.0, step=0.01)
|
| 30 |
+
vitamin_d_level = st.number_input("Vitamin D Level (ng/mL):", min_value=5.0, max_value=100.0, step=0.1)
|
| 31 |
+
|
| 32 |
+
with col3:
|
| 33 |
diet_type = st.selectbox("Diet Type:", options=encoder["Diet_Type"].classes_)
|
| 34 |
diet_type = encoder["Diet_Type"].transform([diet_type])[0]
|
|
|
|
| 35 |
stress_level = st.selectbox("Stress Level:", options=encoder["Stress_Level"].classes_)
|
| 36 |
stress_level = encoder["Stress_Level"].transform([stress_level])[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
glucose_tolerance = st.number_input("Glucose Tolerance Test Result (mg/dL):", min_value=50, max_value=300, step=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
c_protein_level = st.number_input("C-Reactive Protein Level (mg/L):", min_value=0.1, max_value=20.0, step=0.1)
|
|
|
|
| 39 |
cholesterol_level = st.number_input("Cholesterol Level (mg/dL):", min_value=100, max_value=400, step=1)
|
| 40 |
|
| 41 |
# Collect input values into a list
|
|
|
|
| 45 |
|
| 46 |
# Submit button
|
| 47 |
if st.button("Submit"):
|
| 48 |
+
# Preprocess input data
|
| 49 |
values = scaler.transform([values])
|
| 50 |
prediction = model.predict(values)
|
| 51 |
|
| 52 |
+
# Display result
|
| 53 |
if prediction == 1:
|
| 54 |
+
st.error("⚠️ **Risk Alert:** Based on the input data, there is a significant likelihood that the person may be at risk of developing diabetes. It is recommended to consult with a healthcare professional for further evaluation and possible diagnostic tests.")
|
| 55 |
else:
|
| 56 |
+
st.success("✅ **Good News:** Based on the input data, there appears to be no immediate risk of diabetes. Maintaining a healthy lifestyle and regular check-ups are still important for long-term wellness.")
|
| 57 |
+
|