-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict_page.py
67 lines (54 loc) · 1.86 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
import streamlit as st
import pickle
import numpy as np
def load_model():
with open('save_steps.pkl', 'rb') as file:
data = pickle.load(file)
return data
data = load_model()
regressor= data["model"]
le_country = data["le_country"]
le_education = data["le_education"]
def show_predict_page():
st.title("Software Developer Salary Prediction")
st.write("""### We need some information to predict the salary""")
countries = (
'United States of America',
'United Kingdom of Great Britain and Northern Ireland',
'Australia',
'Netherlands',
'Germany',
'Sweden',
'France',
'Spain',
'Brazil',
'Italy',
'Canada',
'Switzerland',
'India',
'Norway',
'Denmark',
'Israel',
'Poland',
)
education = (
"Bachelor’s degree (B.A., B.S., B.Eng., etc.)",
'Some college/university study without earning a degree',
"Master’s degree (M.A., M.S., M.Eng., MBA, etc.)",
'Professional degree (JD, MD, Ph.D, Ed.D, etc.)',
'Associate degree (A.A., A.S., etc.)',
'Secondary school (e.g. American high school, German Realschule or Gymnasium, etc.)',
'Primary/elementary school',
'Something else',
)
selected_country = st.selectbox("Country", countries)
selected_education = st.selectbox("Education Level", education)
selected_experience = st.slider("Years of Experience", 0, 50, 3)
ok = st.button("Calculate Salary")
if ok:
X = np.array([[selected_country, selected_education, selected_experience]])
X[:, 0] = le_country.transform(X[:, 0])
X[:, 1] = le_education.transform(X[:, 1])
X = X.astype(float)
salary = regressor.predict(X)
st.subheader(f"The estimated salary is ${salary[0]:.2f}")