File size: 1,623 Bytes
6f1a339
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
"""Copy of app

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1R-sJnRs7vjJiKyChrebsPbJW374OmZQr
"""

import joblib
import pandas as pd
import streamlit as st

EDU_DICT = {"Bachelor's": 1,
            "Master's": 2,
            "PhD": 3,
            }

model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')

unique_Gender	 = unique_values["Gender"]
unique_Job_Title = unique_values["Job Title"]
unique_Education_Level = unique_values["Education Level"]

def main():
  st.title("Job's Salary Analysis")
  with st.form("questionaire"):
    Age = st.slider("Age", min_value=23, max_value=53)
    Gender = st.selectbox("Gender", unique_Gender)
    Education = st.selectbox("Education Level", unique_Education_Level)
    Job_Title	 = st.selectbox("Job Title", unique_Job_Title)
    Years_of_Experience = st.slider("Years of Experience", min_value=0, max_value=25)

    clicked = st.form_submit_button("Predict Salary")
    if clicked:
        result=model.predict(pd.DataFrame({"Age": [Age],
                                           "Gender": [Gender],
                                           "Job Title": [Job_Title],
                                           "Years of Experience": [Years_of_Experience],
                                           "Education Level": [EDU_DICT[Education]]
                                           }))
        result = '>100K' if result[0] == 1 else '<=100K'
        st.success('The predicted salary is {}'.format(result))

if __name__=='__main__':
    main()