StudentMarksPrediction / src /streamlit_app.py
EnYa32's picture
Update src/streamlit_app.py
1cb2d83 verified
Raw History Blame Contribute Delete
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
# -----------------------------
@st.cache_resource
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**
"""
)