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")