Boorla commited on
Commit
c0e659f
·
verified ·
1 Parent(s): 6a9362d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -6,7 +6,7 @@ from sklearn.preprocessing import LabelEncoder
6
  from sklearn.ensemble import RandomForestClassifier
7
  from sklearn.metrics import accuracy_score, classification_report
8
 
9
- # Load dataset
10
  def load_data():
11
  df = pd.read_csv(r"C:\Users\pavilion\Desktop\INNOMATICS_PROJECTS(SL)\Student_Depresion_Prediction(Machine_Learning)\student_depression_dataset.csv")
12
 
@@ -20,7 +20,7 @@ def load_data():
20
 
21
  return df
22
 
23
- # Preprocess data
24
  def preprocess_data(df):
25
  label_encoders = {}
26
  categorical_cols = df.select_dtypes(include=['object']).columns.tolist()
@@ -32,13 +32,13 @@ def preprocess_data(df):
32
 
33
  return df, label_encoders
34
 
35
- # Train model
36
  def train_model(X_train, y_train):
37
  model = RandomForestClassifier(n_estimators=100, random_state=42)
38
  model.fit(X_train, y_train)
39
  return model
40
 
41
- # Streamlit App
42
  def main():
43
  st.set_page_config(page_title="Student Depression Prediction", layout="wide")
44
 
@@ -75,7 +75,7 @@ def main():
75
  ax.set_title("Feature Importance in Random Forest")
76
  st.pyplot(fig)
77
 
78
- # User Input for Prediction
79
  st.subheader("📊 Predict Depression Risk")
80
  input_data = {}
81
 
@@ -86,7 +86,7 @@ def main():
86
  else:
87
  input_data[col] = st.number_input(f"Enter {col}", min_value=int(X[col].min()), max_value=int(X[col].max()), value=int(X[col].mean()))
88
 
89
- # Prediction Button
90
  if st.button("🔮 Predict"):
91
  input_df = pd.DataFrame([input_data])
92
  prediction = model.predict(input_df)[0]
@@ -112,6 +112,6 @@ def main():
112
  5. **Support Others & Build Strong Friendships** 🤝 - Encourage open discussions and check on friends.
113
  """)
114
 
115
- # Run the Streamlit app
116
  if __name__ == '__main__':
117
  main()
 
6
  from sklearn.ensemble import RandomForestClassifier
7
  from sklearn.metrics import accuracy_score, classification_report
8
 
9
+
10
  def load_data():
11
  df = pd.read_csv(r"C:\Users\pavilion\Desktop\INNOMATICS_PROJECTS(SL)\Student_Depresion_Prediction(Machine_Learning)\student_depression_dataset.csv")
12
 
 
20
 
21
  return df
22
 
23
+
24
  def preprocess_data(df):
25
  label_encoders = {}
26
  categorical_cols = df.select_dtypes(include=['object']).columns.tolist()
 
32
 
33
  return df, label_encoders
34
 
35
+
36
  def train_model(X_train, y_train):
37
  model = RandomForestClassifier(n_estimators=100, random_state=42)
38
  model.fit(X_train, y_train)
39
  return model
40
 
41
+
42
  def main():
43
  st.set_page_config(page_title="Student Depression Prediction", layout="wide")
44
 
 
75
  ax.set_title("Feature Importance in Random Forest")
76
  st.pyplot(fig)
77
 
78
+
79
  st.subheader("📊 Predict Depression Risk")
80
  input_data = {}
81
 
 
86
  else:
87
  input_data[col] = st.number_input(f"Enter {col}", min_value=int(X[col].min()), max_value=int(X[col].max()), value=int(X[col].mean()))
88
 
89
+
90
  if st.button("🔮 Predict"):
91
  input_df = pd.DataFrame([input_data])
92
  prediction = model.predict(input_df)[0]
 
112
  5. **Support Others & Build Strong Friendships** 🤝 - Encourage open discussions and check on friends.
113
  """)
114
 
115
+
116
  if __name__ == '__main__':
117
  main()