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