Praneeth2606 commited on
Commit
095d6cc
Β·
verified Β·
1 Parent(s): 378d4ca

Create pages/6 Deployment.py

Browse files
Files changed (1) hide show
  1. 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")