-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
57 lines (46 loc) Β· 1.54 KB
/
app.py
File metadata and controls
57 lines (46 loc) Β· 1.54 KB
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
import streamlit as st
import joblib
import numpy as np
model = joblib.load("model/student_model.pkl")
st.set_page_config(
page_title="Student Performance Predictor", page_icon="π", layout="centered"
)
st.title("π Student Performance Prefictor")
st.markdown(
"Predict whether a student will **pass or fail** based on scores and preparation."
)
st.divider()
# Input Form
with st.form("prediction_form"):
col1, col2 = st.columns(2)
with col1:
gender = st.selectbox("π€ Gender", ["Female", "Male"])
prep = st.selectbox("π Test Preparation", ["None", "Completed"])
with col2:
math = st.slider("π Math Score", 0, 100, 70)
read = st.slider("π Reading Score", 0, 100, 70)
write = st.slider("βοΈ Writing Score", 0, 100, 70)
submit = st.form_submit_button("π Predict")
if submit:
input_data = np.array(
[
[
1 if gender == "Male" else 0,
math,
read,
write,
1 if prep == "Completed" else 0,
]
]
)
result = model.predict(input_data)[0]
avg_score = round((math + read + write) / 3, 2)
st.markdown("### π Prediction Result")
if result == 1:
st.success(f"β
Likely to Pass (Avg Score: {avg_score})")
st.balloons()
else:
st.error(f"β May Fail (Avg Score: {avg_score})")
st.warning("Encourage more practice or test preparation.")
st.divider()
st.caption("Made with β€οΈ using Streamlit and scikit-learn")