Srikanthgoud7 commited on
Commit
012f0e6
Β·
verified Β·
1 Parent(s): e81347d

Create pages/5 Model Building.py

Browse files
Files changed (1) hide show
  1. pages/5 Model Building.py +52 -0
pages/5 Model Building.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # βš™οΈ Model Building & Evaluation
4
+ st.markdown("""
5
+ ## βš™οΈ Model Building & Evaluation
6
+
7
+ ### πŸ—οΈ Model Building:
8
+
9
+ The classification model was built using the **KNN Classifier**, a robust ensemble learning method suitable for handling both numerical and categorical data.
10
+
11
+ **Model Pipeline:**
12
+
13
+ - **Preprocessing**:
14
+ - Applied **ColumnTransformer** to handle both categorical and numerical features.
15
+ - Used **StandardScaler** for scaling continuous variables.
16
+ - Encoded categorical columns using **OrdinalEncoder** (where appropriate).
17
+
18
+ - **Model**:
19
+ - Trained using **KNearestNeighbors Classifier** from `scikit-learn` with tuned hyperparameters.
20
+
21
+ ---
22
+
23
+ ### βœ… Model Training:
24
+
25
+ - The dataset was split into **training and testing sets** using an 80-20 split.
26
+ - The model was trained on the training set using the engineered features.
27
+ - Proper cross-validation techniques were used to avoid overfitting.
28
+
29
+ ---
30
+
31
+ ### πŸ“Š Model Evaluation:
32
+
33
+ **Evaluation Metrics Used:**
34
+
35
+ - **Accuracy** – Measures the overall correctness of the model.
36
+ - **Precision** – Measures how many predicted "High Risk" projects were actually high risk.
37
+ - **Recall** – Indicates how many actual high-risk projects were correctly identified.
38
+ - **F1 Score** – Harmonic mean of precision and recall for balanced performance.
39
+ - **Confusion Matrix** – Visual breakdown of correct and incorrect classifications.
40
+
41
+ ---
42
+
43
+ The model demonstrated **strong classification performance** on the test dataset, achieving good scores across all metrics.
44
+ It was then saved as a `.pkl` file for deployment and integrated into the Streamlit app for real-time predictions.
45
+ """)
46
+
47
+
48
+ if st.button('Go to Deployment'):
49
+ st.switch_page(r"pages\6.Deployment.py")
50
+
51
+ if st.button('Back'):
52
+ st.switch_page(r"pages\4.Feature Engineering.py")