Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,114 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import pickle
|
| 3 |
-
import numpy as np
|
| 4 |
-
|
| 5 |
-
# Set page title and icon
|
| 6 |
-
st.set_page_config(page_title="Employee Promotion Prediction", page_icon=":guardsman:", layout="wide")
|
| 7 |
-
|
| 8 |
-
# Add a big heading
|
| 9 |
-
st.title("Employee Promotion Prediction")
|
| 10 |
-
|
| 11 |
-
# Change background color to black
|
| 12 |
-
st.markdown(
|
| 13 |
-
"""
|
| 14 |
-
<style>
|
| 15 |
-
.reportview-container {
|
| 16 |
-
background: black
|
| 17 |
-
}
|
| 18 |
-
</style>
|
| 19 |
-
""",
|
| 20 |
-
unsafe_allow_html=True
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
model = pickle.load(open('rf.pkl', 'rb'))
|
| 24 |
-
scaling = pickle.load(open('sc.pkl', 'rb'))
|
| 25 |
-
|
| 26 |
-
# Define the department options
|
| 27 |
-
department_options = ['Analytics', 'Finance', 'HR', 'Legal', 'Operations', 'Procurement', 'R&D', 'Sales & Marketing', 'Technology']
|
| 28 |
-
|
| 29 |
-
# Define the education options
|
| 30 |
-
education_options = ["Bachelor's", "Master's & above", "Below Secondary"]
|
| 31 |
-
|
| 32 |
-
# Define the gender options
|
| 33 |
-
gender_options = ['Male', 'Female']
|
| 34 |
-
|
| 35 |
-
# Define the KPIs met options
|
| 36 |
-
kpis_met_options = ['No', 'Yes']
|
| 37 |
-
|
| 38 |
-
# Define the awards won options
|
| 39 |
-
awards_won_options = ['No', 'Yes']
|
| 40 |
-
|
| 41 |
-
# Define the maximum training score
|
| 42 |
-
max_training_score = 100
|
| 43 |
-
|
| 44 |
-
# Define the maximum number of trainings
|
| 45 |
-
max_trainings = 10
|
| 46 |
-
|
| 47 |
-
# Define the minimum and maximum age
|
| 48 |
-
min_age, max_age = 18, 60
|
| 49 |
-
|
| 50 |
-
# Define the minimum and maximum length of service
|
| 51 |
-
min_service_length, max_service_length = 0, 20
|
| 52 |
-
|
| 53 |
-
# Define the minimum and maximum previous year rating
|
| 54 |
-
min_prev_year_rating, max_prev_year_rating = 1, 5
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
# Define the input components using Streamlit
|
| 58 |
-
|
| 59 |
-
department = st.selectbox('---> Department', department_options)
|
| 60 |
-
education = st.selectbox('---> Education', education_options)
|
| 61 |
-
gender = st.radio('---> Gender', gender_options)
|
| 62 |
-
no_of_trainings = st.number_input('---> Number of Trainings', min_value=1, max_value=max_trainings, value=1)
|
| 63 |
-
age = st.slider('---> Age', min_value=min_age, max_value=max_age)
|
| 64 |
-
previous_year_rating = st.slider('---> Previous Year Rating', min_value=min_prev_year_rating, max_value=max_prev_year_rating)
|
| 65 |
-
length_of_service = st.number_input('---> Length of Service', min_value=min_service_length, max_value=max_service_length, value=0)
|
| 66 |
-
kpis_met = st.selectbox('---> KPIs Met >80%', kpis_met_options)
|
| 67 |
-
awards_won = st.selectbox('---> Awards Won?', awards_won_options)
|
| 68 |
-
avg_training_score = st.number_input('---> Average Training Score', max_value=max_training_score)
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
department_encoding = {'Analytics':0, 'Finance':1, 'HR':2, 'Legal':3, 'Operations':4, 'Procurement':5, 'R&D':6, 'Sales & Marketing':7, 'Technology':8}
|
| 72 |
-
education_encoding = {"Bachelor's":2, "Master's & above":3, "Below Secondary":1}
|
| 73 |
-
gender_encoding = {'Male':1, 'Female':0}
|
| 74 |
-
kpis_met_encoding = {'No':0, 'Yes':1}
|
| 75 |
-
awards_won_encoding = {'No':0, 'Yes':1}
|
| 76 |
-
|
| 77 |
-
sum_metric = awards_won_encoding[awards_won] + kpis_met_encoding[kpis_met] + previous_year_rating
|
| 78 |
-
total_score = avg_training_score * no_of_trainings
|
| 79 |
-
|
| 80 |
-
inputs_to_model = np.array([(department_encoding[department], education_encoding[education],
|
| 81 |
-
gender_encoding[gender], no_of_trainings, age, previous_year_rating,
|
| 82 |
-
length_of_service, kpis_met_encoding[kpis_met], awards_won_encoding[awards_won], avg_training_score,
|
| 83 |
-
sum_metric, total_score)])
|
| 84 |
-
|
| 85 |
-
final_inputs = scaling.transform(inputs_to_model)
|
| 86 |
-
|
| 87 |
-
# Print the user inputs
|
| 88 |
-
if st.button('Submit'):
|
| 89 |
-
# st.write('Department:', department)
|
| 90 |
-
# st.write('Education:', education)
|
| 91 |
-
# st.write('Gender:', gender)
|
| 92 |
-
# st.write('Number of Trainings:', no_of_trainings)
|
| 93 |
-
# st.write('Age:', age)
|
| 94 |
-
# st.write('Previous Year Rating:', previous_year_rating)
|
| 95 |
-
# st.write('Length of Service:', length_of_service)
|
| 96 |
-
# st.write('KPIs Met >80%:', kpis_met)
|
| 97 |
-
# st.write('Awards Won?:', awards_won)
|
| 98 |
-
# st.write('Average Training Score:', avg_training_score)
|
| 99 |
-
# st.write('sum metric', sum_metric)
|
| 100 |
-
# st.write('total score', total_score)
|
| 101 |
-
# st.write('model inputs', inputs_to_model)
|
| 102 |
-
# st.write('final model inputs', final_inputs)
|
| 103 |
-
|
| 104 |
-
prediction = model.predict(final_inputs)
|
| 105 |
-
|
| 106 |
-
if prediction[0] == 1:
|
| 107 |
-
st.header('The Employee should get Promotion')
|
| 108 |
-
|
| 109 |
-
else:
|
| 110 |
-
st.header('The Employee should not get promotion')
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|