xxxqceoqxx commited on
Commit
246b6ca
·
1 Parent(s): 9c422ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -26
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", min_value=10, max_value=100)
46
- workclass = st.selectbox("Workclass", unique_class)
47
- fnlwgt = st.selectbox("fnlwgt",unique_fnlwgt)
48
- education = st.selectbox("Education", unique_education)
49
- educational_num = st.selectbox("educational-num",unique_education_num)
50
- Marital_Status = st.selectbox("Marital Status", unique_marital_status)
51
- occupation = st.selectbox("Occupation", unique_occupation)
52
- relationship = st.selectbox("Relationship", unique_relationship)
53
- race = st.selectbox("Race", unique_race)
54
- gender = st.selectbox("gender", unique_gender)
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],"fnlwgt": [fnlwgt],
64
  "education": [EDU_DICT[education]],
65
- "educational-num": [educational_num],
66
  "marital.status": [Marital_Status],
67
  "occupation": [occupation],
68
  "relationship": [relationship],
69
- "race": [race],
70
- "gender": [gender],"capital_gain": [capital_gain],"capital_loss": [capital-loss],
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