Spaces:
Sleeping
Sleeping
Download src/streamlit_app.py from EnYa32/StudentMarksPrediction: direct link, hf CLI and curl.
- Browser
- Download file 2.67 kB
-
https://huggingface.co/spaces/EnYa32/StudentMarksPrediction/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/EnYa32/StudentMarksPrediction/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/EnYa32/StudentMarksPrediction/resolve/main/src/streamlit_app.py
2.67 kB
| import streamlit as st | |
| import numpy as np | |
| import joblib | |
| # ----------------------------- | |
| # Page config | |
| # ----------------------------- | |
| st.set_page_config( | |
| page_title="Student Grade Prediction", | |
| page_icon="๐", | |
| layout="centered" | |
| ) | |
| # ----------------------------- | |
| # Load model | |
| # ----------------------------- | |
| def load_model(): | |
| model = joblib.load("src/gb_model.pkl") | |
| return model | |
| model = load_model() | |
| # ----------------------------- | |
| # Sidebar | |
| # ----------------------------- | |
| st.sidebar.title("About this app") | |
| st.sidebar.markdown( | |
| """ | |
| This app uses a **Gradient Boosting Regressor** | |
| to predict a student's **marks**. | |
| **Inputs:** | |
| - Number of courses | |
| - Study time per day (hours) | |
| **Output:** | |
| - Predicted marks | |
| """ | |
| ) | |
| st.sidebar.markdown("---") | |
| st.sidebar.markdown("Made for a machine learning regression project. ๐") | |
| # ----------------------------- | |
| # Main title | |
| # ----------------------------- | |
| st.title("๐ Student Grade Prediction App") | |
| st.markdown( | |
| """ | |
| This app predicts the **marks of a student** | |
| based on the **number of courses** and the **study time per day**. | |
| The model was trained using **Gradient Boosting Regression**. | |
| """ | |
| ) | |
| # ----------------------------- | |
| # Input area | |
| # ----------------------------- | |
| st.subheader("Enter student information") | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| number_courses = st.number_input( | |
| "Number of courses", | |
| min_value=1, | |
| max_value=20, | |
| value=5, | |
| step=1, | |
| help="How many courses the student is taking." | |
| ) | |
| with col2: | |
| time_study = st.number_input( | |
| "Study time per day (hours)", | |
| min_value=0.0, | |
| max_value=12.0, | |
| value=4.0, | |
| step=0.5, | |
| help="Average study time per day in hours." | |
| ) | |
| # ----------------------------- | |
| # Prediction | |
| # ----------------------------- | |
| st.markdown("---") | |
| if st.button("๐ฎ Predict Marks"): | |
| # create feature array for model | |
| features = np.array([[number_courses, time_study]]) | |
| # prediction | |
| predicted_marks = model.predict(features)[0] | |
| st.success(f"Predicted marks: **{predicted_marks:.2f}**") | |
| st.markdown( | |
| """ | |
| **Interpretation (simple):** | |
| If the student keeps this study time and number of courses, | |
| the model expects marks close to this value. | |
| """ | |
| ) | |
| # ----------------------------- | |
| # Extra info | |
| # ----------------------------- | |
| with st.expander("Show model details (simple explanation)"): | |
| st.markdown( | |
| """ | |
| - Model type: **GradientBoostingRegressor** | |
| - Target: **Marks** | |
| - Main feature: **Study time per day** | |
| - Secondary feature: **Number of courses** | |
| """ | |
| ) | |