File size: 2,665 Bytes
aebaf45
263e74a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1cb2d83
263e74a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aebaf45
263e74a
 
 
 
 
 
 
 
 
 
 
aebaf45
263e74a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aebaf45
263e74a
aebaf45
263e74a
 
 
 
 
aebaf45
263e74a
aebaf45
263e74a
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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**
        """
    )