Update app.py
Browse files
app.py
CHANGED
@@ -2,67 +2,84 @@ import joblib
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
5 |
-
EDU_DICT = {'Preschool': 1,
|
6 |
-
'1st-4th': 2,
|
7 |
-
'5th-6th': 3,
|
8 |
-
'7th-8th': 4,
|
9 |
-
'9th': 5,
|
10 |
-
'10th': 6,
|
11 |
-
'11th': 7,
|
12 |
-
'12th': 8,
|
13 |
-
'HS-grad': 9,
|
14 |
-
'Some-college': 10,
|
15 |
-
'Assoc-voc': 11,
|
16 |
-
'Assoc-acdm': 12,
|
17 |
-
'Bachelors': 13,
|
18 |
-
'Masters': 14,
|
19 |
-
'Prof-school': 15,
|
20 |
-
'Doctorate': 16
|
21 |
-
}
|
22 |
-
|
23 |
model = joblib.load('model.joblib')
|
24 |
unique_values = joblib.load('unique_values.joblib')
|
25 |
|
26 |
-
unique_class = unique_values["workclass"]
|
27 |
-
unique_education = unique_values["education"]
|
28 |
-
unique_marital_status = unique_values["marital.status"]
|
29 |
-
unique_relationship = unique_values["relationship"]
|
30 |
-
unique_occupation = unique_values["occupation"]
|
31 |
unique_sex = unique_values["sex"]
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
def main():
|
36 |
st.title("Adult Income")
|
37 |
|
38 |
with st.form("questionaire"):
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
# clicked==True only when the button is clicked
|
51 |
-
clicked = st.form_submit_button("Predict
|
52 |
if clicked:
|
53 |
-
result=model.predict(pd.DataFrame({"
|
54 |
-
"
|
55 |
-
"
|
56 |
-
"
|
57 |
-
"
|
58 |
-
"
|
59 |
-
"
|
60 |
-
"
|
61 |
-
"
|
62 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
# Show prediction
|
64 |
-
result = '
|
65 |
-
st.success("
|
66 |
|
67 |
# Run main()
|
68 |
if __name__ == "__main__":
|
|
|
2 |
import pandas as pd
|
3 |
import streamlit as st
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
model = joblib.load('model.joblib')
|
6 |
unique_values = joblib.load('unique_values.joblib')
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
unique_sex = unique_values["sex"]
|
9 |
+
unique_country = unique_values["country"]
|
10 |
+
unique_returning = unique_values["returning"]
|
11 |
+
unique_GImg1 = unique_values["GImg1"]
|
12 |
+
unique_GImg2 = unique_values["GImg2"]
|
13 |
+
unique_GImg3 = unique_values["GImg3"]
|
14 |
+
unique_PImg1 = unique_values["PImg1"]
|
15 |
+
unique_PImg2 = unique_values["PImg2"]
|
16 |
+
unique_PImg3 = unique_values["PImg3"]
|
17 |
+
unique_PImg4= unique_values["PImg4"]
|
18 |
+
unique_PImg5 = unique_values["PImg5"]
|
19 |
+
unique_TAudio1 = unique_values["TAudio1"]
|
20 |
+
unique_TAudio2 = unique_values["TAudio2"]
|
21 |
+
unique_TAudio3 = unique_values["TAudio3"]
|
22 |
+
unique_QAudio1 = unique_values["QAudio1"]
|
23 |
+
unique_QAudio2 = unique_values["QAudio2"]
|
24 |
+
unique_QAudio3 = unique_values["QAudio3"]
|
25 |
+
unique_Proxemics = unique_values["Proxemics"]
|
26 |
+
unique_Authoritative = unique_values["Authoritative .anarchic"]
|
27 |
|
28 |
def main():
|
29 |
st.title("Adult Income")
|
30 |
|
31 |
with st.form("questionaire"):
|
32 |
+
sex = st.selectbox("Sex",options = unique_sex)
|
33 |
+
age = st.slider("Age",min_value=10,max_values=100)
|
34 |
+
country = st.selectbox("Country of the client United Nations admitted countries",options = unique_country)
|
35 |
+
GImg1 = st.selectbox("Handshake Indifferent",options = unique_GImg1)
|
36 |
+
GImg2 = st.selectbox("Hug Indifferent",options = unique_GImg2)
|
37 |
+
GImg3 = st.selectbox("Kiss Indifferent",options = unique_GImg3)
|
38 |
+
PImg1 = st.selectbox("Consent posture Indifferent",options = unique_PImg1)
|
39 |
+
PImg2 = st.selectbox("Interest posture Indifferent",options = unique_PImg2)
|
40 |
+
PImg3 = st.selectbox("Neutral posture Indifferent",options = unique_PImg3)
|
41 |
+
PImg4 = st.selectbox("Reflexive posture Indifferent",options = unique_PImg4)
|
42 |
+
PImg5 = st.selectbox("Negative posture Indifferent",options = unique_PImg5)
|
43 |
+
Tense= st.slider("Observed emotional clime",min_value=1,max_values=10)
|
44 |
+
Authoritativean = st.selectbox("anarchic Observed emotional clime",options = unique_Authoritativean)
|
45 |
+
Hostile = st.slider("friendly Observed emotional clime",min_value=1,max_values=10)
|
46 |
+
TAudio1 = st.selectbox("Authoritative Indifferent",options = unique_TAudio1)
|
47 |
+
TAudio2 = st.selectbox("Sarcastic Indifferent",options = unique_TAudio2)
|
48 |
+
TAudio3 = st.selectbox("Friendly Indifferent",options = unique_TAudio3)
|
49 |
+
QAudio1 = st.selectbox("Spitting Indifferent",options = unique_QAudio1)
|
50 |
+
QAudio2 = st.selectbox("Hum Indifferent",options = unique_QAudio1)
|
51 |
+
QAudio3 = st.selectbox("Sigh Indifferent",options = unique_QAudio1)
|
52 |
+
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)
|
53 |
+
|
54 |
+
|
55 |
|
56 |
# clicked==True only when the button is clicked
|
57 |
+
clicked = st.form_submit_button("Predict Type of Client")
|
58 |
if clicked:
|
59 |
+
result=model.predict(pd.DataFrame({"sex":[sex],
|
60 |
+
"age": [age],
|
61 |
+
"country": [country],
|
62 |
+
"GImg1" : [GImg1],
|
63 |
+
"GImg2" : [GImg2],
|
64 |
+
"GImg3" : [GImg3],
|
65 |
+
"PImg1" : [PImg1],
|
66 |
+
"PImg2" : [PImg2],
|
67 |
+
"PImg3" : [PImg3],
|
68 |
+
"PImg4" : [PImg4],
|
69 |
+
"PImg5" : [PImg5],
|
70 |
+
"Tense-relaxed" :[Tense],
|
71 |
+
"Authoritative-anarchic" : [Authoritative],
|
72 |
+
"Hostile-friendly" : [Hostile],
|
73 |
+
"TAudio1" : [TAudio1],
|
74 |
+
"TAudio2" : [TAudio2],
|
75 |
+
"TAudio3" : [TAudio3],
|
76 |
+
"QAudio1" : [QAudio1],
|
77 |
+
"QAudio2" : [QAudio1],
|
78 |
+
"QAudio3" : [QAudio1],
|
79 |
+
"Proxemics" : [Proxemics]}))
|
80 |
# Show prediction
|
81 |
+
result = 'low' if result[0] == 1 else 'high'
|
82 |
+
st.success("Predict Type of Client is "+result) #แสดงผล
|
83 |
|
84 |
# Run main()
|
85 |
if __name__ == "__main__":
|