File size: 2,585 Bytes
57c64fb
 
01f82b8
57c64fb
01f82b8
 
 
 
 
 
57c64fb
 
01f82b8
 
 
 
 
 
 
 
 
57c64fb
01f82b8
 
 
 
 
57c64fb
 
01f82b8
57c64fb
 
01f82b8
 
 
 
 
 
 
57c64fb
01f82b8
57c64fb
 
 
01f82b8
 
27b9ecc
dff6b18
01f82b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8276f7
01f82b8
 
 
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
61
62
63
64
65
66
67
68
69
import joblib
import pandas as pd
import streamlit as st

EDU_DICT = {'some high school': 1,
            'some college': 2,
            'high school': 3,
            "associate's degree": 4,
            "bachelor's degree": 5,
            "master's degree": 6
            }

race = {'group A': 0,
        'group B': 1,
        'group C': 2,
        'group D': 3,
        'group E': 4
       }

model = joblib.load('modelN.joblib')
unique_values = joblib.load('unique_valuesN.joblib')
    
unique_gender =  unique_values["gender"]
unique_lunch =  unique_values["lunch"]
unique_test_preparation_course =  unique_values["test preparation course"]
unique_education =  unique_values["parental level of education"]


def main():
    st.title("Race Prediction")

    with st.form("questionaire"):
        gender = st.selectbox("gender", options = unique_gender)
        lunch = st.selectbox("lunch", options = unique_lunch)
        test = st.selectbox("test preparation course", options = unique_test_preparation_course)
        education = st.selectbox("parental level of education", options = unique_education)
        math_score = st.slider("math score", min_value = 1, max_value = 100)
        reading_score = st.slider("reading score", min_value = 1, max_value = 100)
        writing_score = st.slider("writing score", min_value = 1, max_value = 100)

                
        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Predict income")
        if clicked:
            result=model.predict(pd.DataFrame({"gender": [gender],
                                               "lunch": [lunch],
                                               "test preparation course": [test],
                                               "parental level of education": [EDU_DICT[education]],
                                               "math score": [math_score],
                                               "reading score": [reading_score],
                                               "writing score": [writing_score]}))
                                             
            if result[0] == 0:
                result = 'group A'
            elif result[0] == 1:
                result = 'group B'
            elif result[0] == 2:
                result = 'group C'
            elif result[0] == 3:
                result = 'group D'
            elif result[0] == 4:
                result = 'group E'
            else:
                'ERROR'
            st.success("Race Prediction is "+result)
            
if __name__ == "__main__":
    main()