File size: 2,159 Bytes
095d6cc 03bf563 095d6cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import streamlit as st
import pandas as pd
import pickle
# Page Title
st.title("π― Student Depression Prediction")
st.subheader("π§Ύ Please fill in the student's details")
# Input Fields
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"])
# Load trained model
with open("demo.pkl", "rb") as f:
knn = pickle.load(f)
# Predict on submit
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") |