-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict_page.py
More file actions
91 lines (74 loc) · 2.26 KB
/
Copy pathpredict_page.py
File metadata and controls
91 lines (74 loc) · 2.26 KB
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
import streamlit as st
import pickle5 as 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"]
le_education = data["le_education"]
le_marital = data["le_marital"]
le_employer = data["le_employer"]
le_occupation = data["le_occupation"]
le_country = data["le_country"]
def show_predict_page():
st.title("Employee Salary Prediction")
st.write("""### We need some information to predict the salary""")
education = (
'Bachelor’s degree',
'HS-Graduate',
'Dropout',
'Master’s',
'Colleges',
'Associates',
'Doctorate',
'Post grad',
)
married = (
' Never-married',
'Married',
'Not-married',
' Widowed',
)
employer = (
'Self-employed',
'Private',
'Federal-gov',
' Without-pay',
)
occupation =(
'Admin',
'White-Collar',
'Blue-Collar',
'Professional',
'Service',
'Sales',
'Military',
)
countries = (
" United-States",
" Mexico",
" Philippines",
" Germany",
" Canada",
" Puerto-Rico",
)
education = st.selectbox("Education Level", education)
married = st.selectbox("About marriage", married)
employer = st.selectbox("Employer", employer)
occupation = st.selectbox("Occupation", occupation)
hours_per_week = st. text_input("hours per week")
country = st.selectbox("Country", countries)
expericence = st.slider("Years of Experience", 0, 30, 3)
ok = st.button("Calculate Salary")
if ok:
X = np.array([[education, expericence,married, employer,occupation,hours_per_week, country]])
X[:, 0] = le_education.transform(X[:, 0])
X[:, 2] = le_marital.transform(X[:, 2])
X[:, 3] = le_employer.transform(X[:, 3])
X[:, 4] = le_occupation.transform(X[:, 4])
X[:, 6] = le_country.transform(X[:, 6])
X = X.astype(float)
salary = regressor.predict(X)
st.subheader(f"The estimated salary is ${salary[0]:.2f}")