Create pages/6 Deployment.py
Browse files- pages/6 Deployment.py +53 -0
pages/6 Deployment.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import pickle
|
4 |
+
|
5 |
+
# Page Title
|
6 |
+
st.title("π― Student Depression Prediction")
|
7 |
+
st.subheader("π§Ύ Please fill in the student's details")
|
8 |
+
|
9 |
+
# Input Fields
|
10 |
+
Gender = st.radio("π€ Gender:", ["Male", "Female"])
|
11 |
+
Age = st.number_input("π Age:", min_value=18.0, max_value=59.0, step=1.0)
|
12 |
+
Academic_pressure = st.radio("π Academic Pressure (1 = Low, 5 = High):", [1., 2., 3., 4., 5.])
|
13 |
+
cgpa = st.number_input("π CGPA (0 - 10):", min_value=0.0, max_value=10.0)
|
14 |
+
study_satisfaction = st.radio("π Study Satisfaction (1 = Low, 5 = High):", [1., 2., 3., 4., 5.])
|
15 |
+
Sleep_Duration = st.radio("π Sleep Duration:", [
|
16 |
+
"Less than 5 hours", "5-6 hours", "7-8 hours", "More than 8 hours"])
|
17 |
+
dietary_habits = st.radio("π₯ Dietary Habits:", ["Unhealthy", "Moderate", "Healthy"])
|
18 |
+
workStudy_Hours = st.slider("π» Work/Study Hours per Day:", min_value=1.0, max_value=12.0, step=1.0)
|
19 |
+
Financial_Stress = st.radio("πΈ Financial Stress (1 = Low, 5 = High):", [1.0, 2.0, 3.0, 4.0, 5.0])
|
20 |
+
Family_History_of_Mental_Illness = st.radio("𧬠Family History of Mental Illness:", ["Yes", "No"])
|
21 |
+
|
22 |
+
# Load trained model
|
23 |
+
with open("demo.pkl", "rb") as f:
|
24 |
+
knn = pickle.load(f)
|
25 |
+
|
26 |
+
# Predict on submit
|
27 |
+
if st.button("π Predict Depression Status"):
|
28 |
+
input_data = pd.DataFrame([{
|
29 |
+
'Gender': Gender,
|
30 |
+
'Age': Age,
|
31 |
+
'Academic Pressure': Academic_pressure,
|
32 |
+
'CGPA': cgpa,
|
33 |
+
'Study Satisfaction': study_satisfaction,
|
34 |
+
'Sleep Duration': Sleep_Duration,
|
35 |
+
'Dietary Habits': dietary_habits,
|
36 |
+
'Work/Study Hours': workStudy_Hours,
|
37 |
+
'Financial Stress': Financial_Stress,
|
38 |
+
'Family History of Mental Illness': Family_History_of_Mental_Illness
|
39 |
+
}])
|
40 |
+
|
41 |
+
prediction = knn.predict(input_data)
|
42 |
+
|
43 |
+
st.markdown("### π§ Depression Prediction Result")
|
44 |
+
if prediction[0] == 1:
|
45 |
+
st.error("π΄ The student is likely experiencing **depression**.")
|
46 |
+
else:
|
47 |
+
st.success("π’ The student is **not likely** experiencing depression.")
|
48 |
+
|
49 |
+
if st.button("<< Back"):
|
50 |
+
st.switch_page(r"pages\5 Model Building.py")
|
51 |
+
|
52 |
+
if st.button("Go to Main Page>>"):
|
53 |
+
st.switch_page("app.py")
|