Spaces:
Runtime error
Runtime error
Commit
·
246b6ca
1
Parent(s):
9c422ba
Update app.py
Browse files
app.py
CHANGED
@@ -24,52 +24,42 @@ model = joblib.load('model.joblib')
|
|
24 |
unique_values = joblib.load('unique_values.joblib')
|
25 |
|
26 |
unique_class = unique_values["workclass"]
|
27 |
-
unique_fnlwgt = unique_values["fnlwgt"]
|
28 |
unique_education = unique_values["education"]
|
29 |
-
unique_education_num = unique_values["educational_num"]
|
30 |
unique_marital_status = unique_values["marital.status"]
|
31 |
-
unique_occupation= unique_values["occupation"]
|
32 |
unique_relationship = unique_values["relationship"]
|
|
|
|
|
33 |
unique_race = unique_values["race"]
|
34 |
-
unique_gender = unique_values["gender"]
|
35 |
-
unique_capital_gain = unique_values["capital_gain"]
|
36 |
-
unique_capital_loss = unique_values["capital_loss"]
|
37 |
-
unique_hours_per_week = unique_values["hours_per_week"]
|
38 |
unique_country = unique_values["native.country"]
|
39 |
-
unique_income = unique_values["income"]
|
40 |
|
41 |
def main():
|
42 |
st.title("Adult Income Analysis")
|
43 |
|
44 |
with st.form("questionaire"):
|
45 |
-
age = st.slider("Age",
|
46 |
-
workclass = st.selectbox("
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
capital_gain = st.selectbox("capital_gain", unique_gender)
|
56 |
-
capital_loss = st.selectbox("capital_loss", unique_gender)
|
57 |
-
hours_per_week = st.slider("Hours per week", min_value=1, max_value=100)
|
58 |
-
native_country = st.selectbox("Country", unique_country)
|
59 |
|
60 |
clicked = st.form_submit_button("Predict income")
|
61 |
if clicked:
|
62 |
result=model.predict(pd.DataFrame({"age": [age],
|
63 |
-
"workclass": [workclass],
|
64 |
"education": [EDU_DICT[education]],
|
65 |
-
"educational-num": [educational_num],
|
66 |
"marital.status": [Marital_Status],
|
67 |
"occupation": [occupation],
|
68 |
"relationship": [relationship],
|
69 |
-
"
|
70 |
-
"
|
71 |
"hours.per.week": [hours_per_week],
|
72 |
"native.country": [native_country]}))
|
|
|
73 |
result = '>50K' if result[0] == 1 else '<=50K'
|
74 |
st.success('The predicted income is {}'.format(result))
|
75 |
|
|
|
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_gender = unique_values["gender"]
|
32 |
unique_race = unique_values["race"]
|
|
|
|
|
|
|
|
|
33 |
unique_country = unique_values["native.country"]
|
|
|
34 |
|
35 |
def main():
|
36 |
st.title("Adult Income Analysis")
|
37 |
|
38 |
with st.form("questionaire"):
|
39 |
+
age = st.slider("Age",min_value = 10 , max_value=100)
|
40 |
+
workclass = st.selectbox("Workcalss", 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 = 1 , max_value=100)
|
48 |
+
native_country =st.selectbox("Native country", options = unique_country)
|
|
|
|
|
|
|
|
|
49 |
|
50 |
clicked = st.form_submit_button("Predict income")
|
51 |
if clicked:
|
52 |
result=model.predict(pd.DataFrame({"age": [age],
|
53 |
+
"workclass": [workclass],
|
54 |
"education": [EDU_DICT[education]],
|
|
|
55 |
"marital.status": [Marital_Status],
|
56 |
"occupation": [occupation],
|
57 |
"relationship": [relationship],
|
58 |
+
"gender": [gender],
|
59 |
+
"sex": [sex],
|
60 |
"hours.per.week": [hours_per_week],
|
61 |
"native.country": [native_country]}))
|
62 |
+
|
63 |
result = '>50K' if result[0] == 1 else '<=50K'
|
64 |
st.success('The predicted income is {}'.format(result))
|
65 |
|