Download pages/5 Model Building.py from Srikanthgoud7/ProjectRiskLevelClassification: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/spaces/Srikanthgoud7/ProjectRiskLevelClassification/resolve/main/pages/5%20Model%20Building.py
- Command line
-
hf download 'hf://spaces/Srikanthgoud7/ProjectRiskLevelClassification/pages/5 Model Building.py'
-
curl -L -o '5 Model Building.py' https://huggingface.co/spaces/Srikanthgoud7/ProjectRiskLevelClassification/resolve/main/pages/5%20Model%20Building.py
1.84 kB
| import streamlit as st | |
| # βοΈ Model Building & Evaluation | |
| st.markdown(""" | |
| ## βοΈ Model Building & Evaluation | |
| ### ποΈ Model Building: | |
| The classification model was built using the **KNN Classifier**, a robust ensemble learning method suitable for handling both numerical and categorical data. | |
| **Model Pipeline:** | |
| - **Preprocessing**: | |
| - Applied **ColumnTransformer** to handle both categorical and numerical features. | |
| - Used **StandardScaler** for scaling continuous variables. | |
| - Encoded categorical columns using **OrdinalEncoder** (where appropriate). | |
| - **Model**: | |
| - Trained using **KNearestNeighbors Classifier** from `scikit-learn` with tuned hyperparameters. | |
| --- | |
| ### β Model Training: | |
| - The dataset was split into **training and testing sets** using an 80-20 split. | |
| - The model was trained on the training set using the engineered features. | |
| - Proper cross-validation techniques were used to avoid overfitting. | |
| --- | |
| ### π Model Evaluation: | |
| **Evaluation Metrics Used:** | |
| - **Accuracy** β Measures the overall correctness of the model. | |
| - **Precision** β Measures how many predicted "High Risk" projects were actually high risk. | |
| - **Recall** β Indicates how many actual high-risk projects were correctly identified. | |
| - **F1 Score** β Harmonic mean of precision and recall for balanced performance. | |
| - **Confusion Matrix** β Visual breakdown of correct and incorrect classifications. | |
| --- | |
| The model demonstrated **strong classification performance** on the test dataset, achieving good scores across all metrics. | |
| It was then saved as a **.pkl** file for deployment and integrated into the Streamlit app for real-time predictions. | |
| """) | |
| if st.button('Go to Deployment'): | |
| st.switch_page("pages/6 Deployment.py") | |
| if st.button('Back'): | |
| st.switch_page("pages/4 Feature Engineering.py") |