Thanatcha commited on
Commit
dd050b2
·
1 Parent(s): 086bb9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -32
app.py CHANGED
@@ -24,46 +24,33 @@ remote_ratio_dict = {'0':1,
24
  model = joblib.load('model.joblib')
25
  unique_values = joblib.load('unique_values.joblib')
26
 
27
- unique_class = unique_values["workclass"]
28
- unique_education = unique_values["education"]
29
- unique_marital_status = unique_values["marital.status"]
30
- unique_relationship = unique_values["relationship"]
31
- unique_occupation = unique_values["occupation"]
32
- unique_sex = unique_values["sex"]
33
- unique_race = unique_values["race"]
34
- unique_native_country = unique_values["native.country"]
35
 
36
  def main():
37
- st.title("Adult Income")
38
 
39
  with st.form("questionaire"):
40
- age = st.slider("Age", min_value = 10, max_value = 100)
41
- workclass = st.selectbox("Workclass", options=unique_class)
42
- education = st.selectbox("Education", options=unique_education)
43
- Marital_Status = st.selectbox("Marital Status", options=unique_marital_status)
44
- occupation = st.selectbox("Occupation", options=unique_occupation)
45
- relationship = st.selectbox("Relationship", options=unique_relationship)
46
- race = st.selectbox("Race", options=unique_race)
47
- sex = st.selectbox("Sex", options=unique_sex)
48
- hours_per_week = st.slider("Hours per week", min_value = 10, max_value = 100)
49
- native_country = st.selectbox("Native country", options=unique_native_country)
50
 
51
  # clicked==True only when the button is clicked
52
- clicked = st.form_submit_button("Predict income")
53
  if clicked:
54
- result=model.predict(pd.DataFrame({"age": [age],
55
- "workclass": [workclass],
56
- "education": [EDU_DICT[education]],
57
- "marital.status": [Marital_Status],
58
- "occupation": [occupation],
59
- "relationship": [relationship],
60
- "race": [race],
61
- "sex": [sex],
62
- "hours.per.week": [hours_per_week],
63
- "native.country": [native_country]}))
64
  # Show prediction
65
- result = ">50K" if result[0] == 1 else "<=50K"
66
- st.success("Your predicted income is " +result)
67
 
68
  if __name__ == "__main__":
69
  main()
 
24
  model = joblib.load('model.joblib')
25
  unique_values = joblib.load('unique_values.joblib')
26
 
27
+ unique_experience_level = unique_values["experience_level"]
28
+ unique_employment_type = unique_values["employment_type"]
29
+ unique_job_title = unique_values["job_title"]
30
+ unique_remote_ratio = unique_values["remote_ratio"]
31
+ unique_company_size = unique_values["company_size"]
 
 
 
32
 
33
  def main():
34
+ st.title("Data Science Job Salaries")
35
 
36
  with st.form("questionaire"):
37
+ experience_level = st.selectbox("The experience level in the job", options = unique_experience_level)
38
+ employment_type = st.selectbox("The type of employement for the role", options=unique_employment_type)
39
+ job_title = st.selectbox("The role worked", options=unique_job_title)
40
+ remote_ratio = st.selectbox("The overall amount of work done remotely", options=unique_remote_ratio)
41
+ company_size = st.selectbox("The average number of people that worked for the company", options=unique_company_size)
 
 
 
 
 
42
 
43
  # clicked==True only when the button is clicked
44
+ clicked = st.form_submit_button("Predict Data Science Job Salaries")
45
  if clicked:
46
+ result=model.predict(pd.DataFrame({"experience_level": [Experience_DICT[experience_level],
47
+ "employment_type": [employment_type_dict[employment_type]],
48
+ "job_title": [job_title],
49
+ "remote_ratio": [remote_ratio],
50
+ "company_size": [Company_size[company_size]]}))
 
 
 
 
 
51
  # Show prediction
52
+ salary_in_usd = str(round(float(result),2))
53
+ st.success("Your predicted Data Science job salaries in usd is " +result)
54
 
55
  if __name__ == "__main__":
56
  main()