Spaces:
Runtime error
Runtime error
Commit
·
c9b0186
1
Parent(s):
b544d4a
Update app.py
Browse files
app.py
CHANGED
@@ -53,26 +53,27 @@ def main():
|
|
53 |
hours_per_week = st.slider("Hours per week", min_value=1, max_value=100)
|
54 |
native_country = st.selectbox("Country",options = unique_country)
|
55 |
|
56 |
-
clicked
|
57 |
-
if
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
76 |
|
77 |
if __name__ == '__main__':
|
78 |
|
|
|
53 |
hours_per_week = st.slider("Hours per week", min_value=1, max_value=100)
|
54 |
native_country = st.selectbox("Country",options = unique_country)
|
55 |
|
56 |
+
if clicked:
|
57 |
+
education_encoded = EDU_DICT.get(education, 0) # Default to 0 if education is not found
|
58 |
+
result = model.predict(pd.DataFrame({
|
59 |
+
"age": [age],
|
60 |
+
"workclass": [workclass],
|
61 |
+
"fnlwgt": [fnlwgt],
|
62 |
+
"education": [education_encoded],
|
63 |
+
"educational-num": [educational_num],
|
64 |
+
"marital.status": [marital_status],
|
65 |
+
"occupation": [occupation],
|
66 |
+
"relationship": [relationship],
|
67 |
+
"race": [race],
|
68 |
+
"gender": [gender],
|
69 |
+
"capital_gain": [capital_gain],
|
70 |
+
"capital_loss": [capital_loss],
|
71 |
+
"hours.per.week": [hours_per_week],
|
72 |
+
"native.country": [native_country]
|
73 |
+
}))
|
74 |
+
result = '>50K' if result[0] == 1 else '<=50K'
|
75 |
+
st.success('The predicted income is {}'.format(result))
|
76 |
+
|
77 |
|
78 |
if __name__ == '__main__':
|
79 |
|