|
import streamlit as st |
|
import pandas as pd |
|
import pickle |
|
|
|
|
|
st.title("π― Student Depression Prediction") |
|
st.subheader("π§Ύ Please fill in the student's details") |
|
|
|
|
|
Gender = st.radio("π€ Gender:", ["Male", "Female"]) |
|
Age = st.number_input("π Age:", min_value=18.0, max_value=59.0, step=1.0) |
|
Academic_pressure = st.radio("π Academic Pressure (1 = Low, 5 = High):", [1., 2., 3., 4., 5.]) |
|
cgpa = st.number_input("π CGPA (0 - 10):", min_value=0.0, max_value=10.0) |
|
study_satisfaction = st.radio("π Study Satisfaction (1 = Low, 5 = High):", [1., 2., 3., 4., 5.]) |
|
Sleep_Duration = st.radio("π Sleep Duration:", [ |
|
"Less than 5 hours", "5-6 hours", "7-8 hours", "More than 8 hours"]) |
|
dietary_habits = st.radio("π₯ Dietary Habits:", ["Unhealthy", "Moderate", "Healthy"]) |
|
workStudy_Hours = st.slider("π» Work/Study Hours per Day:", min_value=1.0, max_value=12.0, step=1.0) |
|
Financial_Stress = st.radio("πΈ Financial Stress (1 = Low, 5 = High):", [1.0, 2.0, 3.0, 4.0, 5.0]) |
|
Family_History_of_Mental_Illness = st.radio("𧬠Family History of Mental Illness:", ["Yes", "No"]) |
|
|
|
|
|
with open("demo.pkl", "rb") as f: |
|
knn = pickle.load(f) |
|
|
|
|
|
if st.button("π Predict Depression Status"): |
|
input_data = pd.DataFrame([{ |
|
'Gender': Gender, |
|
'Age': Age, |
|
'Academic Pressure': Academic_pressure, |
|
'CGPA': cgpa, |
|
'Study Satisfaction': study_satisfaction, |
|
'Sleep Duration': Sleep_Duration, |
|
'Dietary Habits': dietary_habits, |
|
'Work/Study Hours': workStudy_Hours, |
|
'Financial Stress': Financial_Stress, |
|
'Family History of Mental Illness': Family_History_of_Mental_Illness |
|
}]) |
|
|
|
prediction = knn.predict(input_data) |
|
|
|
st.markdown("### π§ Depression Prediction Result") |
|
if prediction[0] == 1: |
|
st.error("π΄ The student is likely experiencing **depression**.") |
|
else: |
|
st.success("π’ The student is **not likely** experiencing depression.") |
|
|
|
if st.button("<< Back"): |
|
st.switch_page(r"pages/5 Model Building.py") |
|
|
|
if st.button("Go to Main Page>>"): |
|
st.switch_page("app.py") |