Download src/streamlit_app.py from MSK34/Student-Performance-Prediction: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/spaces/MSK34/Student-Performance-Prediction/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/MSK34/Student-Performance-Prediction/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/MSK34/Student-Performance-Prediction/resolve/main/src/streamlit_app.py
1.56 kB
| 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)) |