Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +53 -0
- model.pkl +3 -0
- requirements.txt +9 -0
app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import mlflow
|
3 |
+
import mlflow.sklearn
|
4 |
+
import pandas as pd
|
5 |
+
import numpy as np
|
6 |
+
from sklearn.preprocessing import LabelEncoder
|
7 |
+
import joblib
|
8 |
+
|
9 |
+
logged_model = 'model.pkl'
|
10 |
+
model = joblib.load(logged_model)
|
11 |
+
|
12 |
+
categorical_features = ['employment_type', 'job_category', 'experience_level',
|
13 |
+
'employee_residence', 'remote_ratio', 'company_location', 'company_size']
|
14 |
+
|
15 |
+
distinct_values = {
|
16 |
+
'experience_level': ['Senior-level/Expert','Mid-level/Intermediate', 'Entry-level/Junior'],
|
17 |
+
'employment_type': ['Full-time', 'Contractor', 'Freelancer', 'Part-time'],
|
18 |
+
'employee_residence': ['ES', 'US', 'CA', 'DE', 'GB', 'NG', 'IN', 'HK', 'PT', 'NL', 'CH', 'CF', 'FR', 'AU',
|
19 |
+
'FI', 'UA', 'IE', 'IL', 'GH', 'AT', 'CO', 'SG', 'SE', 'SI', 'MX', 'UZ', 'BR', 'TH',
|
20 |
+
'HR', 'PL', 'KW', 'VN', 'CY', 'AR', 'AM', 'BA', 'KE', 'GR', 'MK', 'LV', 'RO', 'PK',
|
21 |
+
'IT', 'MA', 'LT', 'BE', 'AS', 'IR', 'HU', 'SK', 'CN', 'CZ', 'CR', 'TR', 'CL', 'PR',
|
22 |
+
'DK', 'BO', 'PH', 'DO', 'EG', 'ID', 'AE', 'MY', 'JP', 'EE', 'HN', 'TN', 'RU', 'DZ',
|
23 |
+
'IQ', 'BG', 'JE', 'RS', 'NZ', 'MD', 'LU', 'MT'],
|
24 |
+
'remote_ratio': ['Full-Remote', 'On-Site', 'Half-Remote'],
|
25 |
+
'company_location': ['ES', 'US', 'CA', 'DE', 'GB', 'NG', 'IN', 'HK', 'NL', 'CH', 'CF', 'FR', 'FI', 'UA',
|
26 |
+
'IE', 'IL', 'GH', 'CO', 'SG', 'AU', 'SE', 'SI', 'MX', 'BR', 'PT', 'RU', 'TH', 'HR',
|
27 |
+
'VN', 'EE', 'AM', 'BA', 'KE', 'GR', 'MK', 'LV', 'RO', 'PK', 'IT', 'MA', 'PL', 'AL',
|
28 |
+
'AR', 'LT', 'AS', 'CR', 'IR', 'BS', 'HU', 'AT', 'SK', 'CZ', 'TR', 'PR', 'DK', 'BO',
|
29 |
+
'PH', 'BE', 'ID', 'EG', 'AE', 'LU', 'MY', 'HN', 'JP', 'DZ', 'IQ', 'CN', 'NZ', 'CL',
|
30 |
+
'MD', 'MT'],
|
31 |
+
'company_size': ['LARGE', 'SMALL', 'MEDIUM'],
|
32 |
+
'job_category': ['Other', 'Machine Learning', 'Data Science', 'Data Engineering',
|
33 |
+
'Data Architecture', 'Management']
|
34 |
+
}
|
35 |
+
|
36 |
+
encoders = {feature: LabelEncoder().fit(values) for feature, values in distinct_values.items()}
|
37 |
+
|
38 |
+
st.title("Salary Prediction")
|
39 |
+
|
40 |
+
user_input = {}
|
41 |
+
for feature in categorical_features:
|
42 |
+
user_input[feature] = st.selectbox(f"Select {feature}",distinct_values[feature])
|
43 |
+
|
44 |
+
encoded_input = [encoders[feature].transform([user_input[feature]])[0] for feature in categorical_features]
|
45 |
+
|
46 |
+
if st.button("Predict Salary Range"):
|
47 |
+
encoded_input = np.array(encoded_input).reshape(1, -1)
|
48 |
+
prediction = model.predict(encoded_input)
|
49 |
+
|
50 |
+
salary_labels = ['low', 'low-mid', 'mid', 'mid-high', 'high', 'very-high', 'Top']
|
51 |
+
|
52 |
+
st.write(f"Predicted Salary Range: {prediction}")
|
53 |
+
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cb44f42ac391ccfd1084c31d320133311372c03a5fe17ebc9bee0279a65192d7
|
3 |
+
size 917383
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
numpy==2.0.0
|
2 |
+
pandas
|
3 |
+
matplotlib
|
4 |
+
seaborn
|
5 |
+
plotly
|
6 |
+
scipy
|
7 |
+
scikit-learn
|
8 |
+
mlflow
|
9 |
+
streamlit
|