File size: 1,564 Bytes
e190f7a 45bb39d e190f7a 45bb39d e190f7a 45bb39d e190f7a 45bb39d | 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 | import streamlit as st
import pandas as pd
import joblib
st.title("Student Performance Prediction")
st.write("This app predicts a student's math score using regression model.")
model = joblib.load("src/student_performance_model.pkl")
feature_columns = joblib.load("src/feature_columns.pkl")
gender = st.selectbox("Gender", ["female", "male"])
race = st.selectbox("Race/Ethnicity", ["group A", "group B", "group C", "group D", "group E"])
parent_education = st.selectbox(
"Parental Level of Education",
[
"some high school",
"high school",
"some college",
"associate's degree",
"bachelor's degree",
"master's degree"
]
)
lunch = st.selectbox("Lunch", ["standard", "free/reduced"])
test_prep = st.selectbox("Test Preparation Course", ["none", "completed"])
reading_score = st.number_input("Reading Score", min_value=0, max_value=100, value=70)
writing_score = st.number_input("Writing Score", min_value=0, max_value=100, value=70)
input_data = pd.DataFrame({
"gender": [gender],
"race/ethnicity": [race],
"parental level of education": [parent_education],
"lunch": [lunch],
"test preparation course": [test_prep],
"reading score": [reading_score],
"writing score": [writing_score]
})
input_data = pd.get_dummies(input_data, drop_first=True)
input_data = input_data.reindex(columns=feature_columns, fill_value=0)
if st.button("Predict Math Score"):
prediction = model.predict(input_data)
st.subheader("Predicted Math Score")
st.write(round(prediction[0], 2)) |