Create pages/5 Model Building.py
Browse files- pages/5 Model Building.py +41 -0
pages/5 Model Building.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Page Title
|
4 |
+
st.title("βοΈ Model Building & Evaluation")
|
5 |
+
|
6 |
+
# Model Building Section
|
7 |
+
st.markdown("""
|
8 |
+
### ποΈ Model Building:
|
9 |
+
The classification model was built using the **K-Nearest Neighbors (KNN) Classifier**, which predicts a student's depression status based on similar instances in the training data.
|
10 |
+
|
11 |
+
#### Model Pipeline:
|
12 |
+
- **Preprocessing**: Encoding and scaling were handled using `ColumnTransformer` with `OrdinalEncoder` and `StandardScaler`.
|
13 |
+
- **Train-Test Split**: The dataset was split into training and testing sets using `train_test_split` with **stratification** on the target to preserve class balance.
|
14 |
+
- **Model**: Implemented using `KNeighborsClassifier` from scikit-learn.
|
15 |
+
""")
|
16 |
+
|
17 |
+
# Model Training Section
|
18 |
+
st.markdown("""
|
19 |
+
### β
Model Training:
|
20 |
+
- The model was trained on the processed dataset with optimized hyperparameters.
|
21 |
+
- `GridSearchCV` was used to find the best value of `k` (number of neighbors).
|
22 |
+
- Cross-validation ensured the robustness of the trained model.
|
23 |
+
""")
|
24 |
+
|
25 |
+
# Model Evaluation Section
|
26 |
+
st.markdown("""
|
27 |
+
### π Model Evaluation:
|
28 |
+
|
29 |
+
**Metrics Used:**
|
30 |
+
- Accuracy Score
|
31 |
+
- Classification Report (Precision, Recall, F1-score)
|
32 |
+
- Confusion Matrix
|
33 |
+
|
34 |
+
The trained model demonstrated good performance on the test data and was exported as a `.pkl` file for deployment in the Hugging Face.
|
35 |
+
""")
|
36 |
+
|
37 |
+
if st.button("Go to Deployment >>"):
|
38 |
+
st.switch_page(r"pages\6 Deployment.py")
|
39 |
+
|
40 |
+
if st.button("<< Back"):
|
41 |
+
st.switch_page(r"pages\4 Feature Engineering.py")
|