|
|
|
"""Lab07_Deployment_on_HuggingFace_Spaces_backend.ipynb |
|
|
|
Automatically generated by Colaboratory. |
|
|
|
Original file is located at |
|
https://colab.research.google.com/drive/18LL9Kki70qRHvNJQFYMtTe4TwJRJ97x9 |
|
""" |
|
|
|
import joblib |
|
import pandas as pd |
|
import streamlit as st |
|
|
|
EDU_DICT = {"bachelor's degree": 1, |
|
'some college': 2, |
|
"master's degree": 3, |
|
"associate's degree": 4, |
|
'high school': 5, |
|
'some high school': 6, |
|
} |
|
|
|
model = joblib.load('model.joblib') |
|
unique_values = joblib.load('unique_values.joblib') |
|
|
|
unique_gender = unique_values["gender"] |
|
unique_race_ethnicity = unique_values["race/ethnicity"] |
|
unique_level_of_education = unique_values["parental level of education"] |
|
unique_lunch = unique_values["lunch"] |
|
|
|
|
|
|
|
def main(): |
|
|
|
st.title("Students Performance Analysis") |
|
|
|
with st.form("questionaire"): |
|
gender = st.selectbox("gender", unique_gender) |
|
race_ethnicity = st.selectbox("race/ethnicity", unique_race_ethnicity) |
|
level_of_education = st.selectbox("parental level of education", unique_level_of_education) |
|
lunch = st.selectbox("lunch", unique_lunch) |
|
math_score = st.slider("math score", min_value=0, max_value=100) |
|
reading_score = st.slider("reading score", min_value=17, max_value=100) |
|
writing_score = st.slider("writing score", min_value=10, max_value=100) |
|
|
|
clicked = st.form_submit_button("Predict Students Performance") |
|
|
|
if clicked: |
|
result= model.predict(pd.DataFrame({"gender": [gender], |
|
"race/ethnicity": [race_ethnicity], |
|
"parental level of education": [EDU_DICT[level_of_education]], |
|
"lunch": [lunch], |
|
"math score": [math_score], |
|
"reading score": [reading_score], |
|
"writing score": [writing_score] |
|
})) |
|
result = 'completed' if result[0] == 1 else 'none' |
|
st.success('The predicted students performance is {}'.format(result)) |
|
|
|
if __name__=='__main__': |
|
main() |