File size: 2,223 Bytes
df72932
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -*- coding: utf-8 -*-
"""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()