-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict_page.py
110 lines (98 loc) · 2.63 KB
/
predict_page.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import streamlit as st
import pickle
import numpy as np
def load_model():
with open('saved_steps.pkl', 'rb') as file:
data = pickle.load(file)
return data
data = load_model()
regressor = data["model"]
label_country = data["label_country"]
label_education = data["label_education"]
label_gender = data["label_gender"]
def show_predict_page():
st.title("Developer Salary Prediction")
st.write("""
## We need some information to predict the Salary
""")
countries = (
'Argentina',
'Australia',
'Austria',
'Bangladesh',
'Belgium',
'Brazil',
'Bulgaria',
'Canada',
'Chile',
'China',
'Colombia',
'Croatia',
'Czech Republic',
'Denmark',
'Egypt',
'Finland',
'France',
'Germany',
'Greece',
'Hungary',
'India',
'Indonesia',
'Iran',
'Ireland',
'Israel',
'Italy',
'Japan',
'Lithuania',
'Malaysia',
'Mexico',
'Netherlands',
'New Zealand',
'Nigeria',
'Norway',
'Other',
'Pakistan',
'Philippines',
'Poland',
'Portugal',
'Romania',
'Russian Federation',
'Serbia',
'Singapore',
'Slovenia',
'South Africa',
'Spain',
'Sri Lanka',
'Sweden',
'Switzerland',
'Taiwan',
'Turkey',
'Ukraine',
'United Kingdom of Great Britain and Northern Ireland',
'United States of America',
'Viet Nam'
)
education = (
'Less than a Bachelors',
'Bachelor’s degree',
'Master’s degree',
'Post grad'
)
gender = (
'Man',
'Woman',
'Others'
)
country = st.selectbox("Country", countries)
education = st.selectbox("Education", education)
gender = st.selectbox("Gender", gender)
experience = st.slider("Years of Experience", 0, 40, 2)
sal = st.button("Calculate Salary")
if sal:
X = np.array([[country, education, experience, gender]])
X[:, 0] = label_country.transform(X[:,0])
X[:, 1] = label_education.transform(X[:,1])
X[:, 3] = label_gender.transform(X[:,3])
X = X.astype(float)
salary = regressor.predict(X)
st.subheader(f"The estimated salary is ${salary[0]:.2f}")