Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,18 +36,20 @@ def main():
|
|
36 |
st.title("Adult Income")
|
37 |
|
38 |
with st.form("questionaire"):
|
39 |
-
age =
|
40 |
-
workclass =
|
41 |
-
education =
|
42 |
-
Marital_Status =
|
43 |
-
occupation =
|
44 |
-
relationship =
|
45 |
-
race =
|
46 |
-
sex =
|
47 |
-
hours_per_week =
|
48 |
-
native_country =
|
49 |
|
50 |
# clicked==True only when the button is clicked
|
|
|
|
|
51 |
clicked = st.form_submit_button("Predict income")
|
52 |
if clicked:
|
53 |
result=model.predict(pd.DataFrame({"age": [age],
|
@@ -58,8 +60,11 @@ def main():
|
|
58 |
"relationship": [relationship],
|
59 |
"race": [race],
|
60 |
"sex": [sex],
|
61 |
-
"hours.per.week":
|
62 |
"native.country": [native_country]}))
|
63 |
# Show prediction
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
36 |
st.title("Adult Income")
|
37 |
|
38 |
with st.form("questionaire"):
|
39 |
+
age = st.slider("Age", min_value=10, max_value=100)
|
40 |
+
workclass = st.selectbox("Workclass",options=unique_class)
|
41 |
+
education = st.selectbox("Education",options=unique_education)
|
42 |
+
Marital_Status = st.selectbox("Marital Status",options=unique_marital_status)
|
43 |
+
occupation = st.selectbox("Occupation",options=unique_occupation )
|
44 |
+
relationship = st.selectbox("Relationship",options=unique_relationship)
|
45 |
+
race = st.selectbox("Race",options=unique_race)
|
46 |
+
sex = st.selectbox("Sex",options=unique_sex)
|
47 |
+
hours_per_week = st.slider("Hours per week", min_value=10, max_value=100)
|
48 |
+
native_country = st.selectbox("Native country",options=unique_native_country)
|
49 |
|
50 |
# clicked==True only when the button is clicked
|
51 |
+
# เป็นจริงก็ต่อเมื่อ user กดปุ่มเท่านั้น
|
52 |
+
# result คลาย list ออกมา
|
53 |
clicked = st.form_submit_button("Predict income")
|
54 |
if clicked:
|
55 |
result=model.predict(pd.DataFrame({"age": [age],
|
|
|
60 |
"relationship": [relationship],
|
61 |
"race": [race],
|
62 |
"sex": [sex],
|
63 |
+
"hours.per.week":[hours_per_week],
|
64 |
"native.country": [native_country]}))
|
65 |
# Show prediction
|
66 |
+
result = ">50k" if result[0] == 1 else"<=50k"
|
67 |
+
st.success("Your finished income is "+result)
|
68 |
+
|
69 |
+
if __name__="__main__":
|
70 |
+
main()
|