File size: 4,725 Bytes
4ffe25a
 
 
 
 
 
 
 
f67ddfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ffe25a
 
 
 
 
f67ddfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ffe25a
 
f67ddfb
4ffe25a
f67ddfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ffe25a
f67ddfb
 
4ffe25a
 
 
 
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import joblib
import pandas as pd
import streamlit as st

model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')
    
unique_sex =  unique_values["sex"]
unique_country =  unique_values["country"]
unique_returning =  unique_values["returning"]
unique_GImg1 =  unique_values["GImg1"]
unique_GImg2 =  unique_values["GImg2"]
unique_GImg3 =  unique_values["GImg3"]
unique_PImg1 =  unique_values["PImg1"]
unique_PImg2 =  unique_values["PImg2"]
unique_PImg3 =  unique_values["PImg3"]
unique_PImg4=  unique_values["PImg4"]
unique_PImg5 =  unique_values["PImg5"]
unique_TAudio1  =  unique_values["TAudio1"]
unique_TAudio2  =  unique_values["TAudio2"]
unique_TAudio3  =  unique_values["TAudio3"]
unique_QAudio1  =  unique_values["QAudio1"]
unique_QAudio2  =  unique_values["QAudio2"]
unique_QAudio3  =  unique_values["QAudio3"]
unique_Proxemics  =  unique_values["Proxemics"]
unique_Authoritative  =  unique_values["Authoritative .anarchic"]

def main():
    st.title("Adult Income")

    with st.form("questionaire"):
        sex = st.selectbox("Sex",options = unique_sex)
        age = st.slider("Age",min_value=10,max_values=100)
        country = st.selectbox("Country of the client United Nations admitted countries",options = unique_country)
        GImg1 = st.selectbox("Handshake Indifferent",options = unique_GImg1)
        GImg2 = st.selectbox("Hug Indifferent",options = unique_GImg2)
        GImg3 = st.selectbox("Kiss Indifferent",options = unique_GImg3)
        PImg1 = st.selectbox("Consent posture Indifferent",options = unique_PImg1)
        PImg2 = st.selectbox("Interest posture Indifferent",options = unique_PImg2)
        PImg3 = st.selectbox("Neutral posture Indifferent",options = unique_PImg3)
        PImg4 = st.selectbox("Reflexive posture Indifferent",options = unique_PImg4)
        PImg5 = st.selectbox("Negative posture Indifferent",options = unique_PImg5)
        Tense= st.slider("Observed emotional clime",min_value=1,max_values=10)
        Authoritativean = st.selectbox("anarchic Observed emotional clime",options = unique_Authoritativean)
        Hostile = st.slider("friendly Observed emotional clime",min_value=1,max_values=10)
        TAudio1 = st.selectbox("Authoritative Indifferent",options = unique_TAudio1)
        TAudio2 = st.selectbox("Sarcastic Indifferent",options = unique_TAudio2)   
        TAudio3 = st.selectbox("Friendly Indifferent",options = unique_TAudio3)   
        QAudio1 = st.selectbox("Spitting Indifferent",options = unique_QAudio1)   
        QAudio2 = st.selectbox("Hum Indifferent",options = unique_QAudio1)   
        QAudio3 = st.selectbox("Sigh Indifferent",options = unique_QAudio1)   
        Proxemics = st.selectbox("Physical distance preferred for the client : A. intimate: 15cm-45cm; B. per-sonal: 46cm-122cm; C. social:123cm-360cm; D. public: > 360cm",options = unique_Proxemics)
        


        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Predict Type of Client")
        if clicked:
            result=model.predict(pd.DataFrame({"sex":[sex],
                                               "age": [age],
                                               "country": [country],
                                               "GImg1" : [GImg1],
                                               "GImg2" : [GImg2],
                                               "GImg3" : [GImg3],
                                               "PImg1" : [PImg1],
                                               "PImg2" : [PImg2],
                                               "PImg3" : [PImg3],
                                               "PImg4" : [PImg4],
                                               "PImg5" : [PImg5],
                                               "Tense-relaxed" :[Tense],
                                               "Authoritative-anarchic" : [Authoritative],
                                               "Hostile-friendly" : [Hostile],
                                               "TAudio1" : [TAudio1],
                                               "TAudio2" : [TAudio2],
                                               "TAudio3" : [TAudio3],
                                               "QAudio1" : [QAudio1],  
                                               "QAudio2" : [QAudio1],  
                                               "QAudio3" : [QAudio1],
                                               "Proxemics" : [Proxemics]}))
            # Show prediction
            result = 'low' if result[0] == 1 else 'high'
            st.success("Predict Type of Client is "+result) #แสดงผล
            
# Run main()
if __name__ == "__main__":
    main()