xxxqceoqxx commited on
Commit
c9b0186
·
1 Parent(s): b544d4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -20
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 = st.form_submit_button("Predict income")
57
- if clicked:
58
- education_encoded = EDU_DICT.get(education, 0) # Default to 0 if education is not found
59
- result = model.predict(pd.DataFrame({
60
- "age": [age],
61
- "workclass": [workclass],
62
- "fnlwgt": [fnlwgt],
63
- "education": [education_encoded],
64
- "educational-num": [educational_num],
65
- "marital.status": [marital_status],
66
- "occupation": [occupation],
67
- "relationship": [relationship],
68
- "race": [race],
69
- "gender": [gender],
70
- "capital_gain": [capital_gain],
71
- "capital_loss": [capital_loss],
72
- "hours.per.week": [hours_per_week],
73
- "native.country": [native_country]}))
74
- result = '>50K' if result[0] == 1 else '<=50K'
75
- st.success('The predicted income is {}'.format(result))
 
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