import streamlit as st import pickle import numpy as np # Set page title and icon st.set_page_config(page_title="Employee Promotion Prediction", page_icon=":guardsman:", layout="wide") # Add a big heading st.title("Employee Promotion Prediction") # Change background color to black st.markdown( """ """, unsafe_allow_html=True ) model = pickle.load(open('rf.pkl', 'rb')) scaling = pickle.load(open('sc.pkl', 'rb')) # Define the department options department_options = ['Analytics', 'Finance', 'HR', 'Legal', 'Operations', 'Procurement', 'R&D', 'Sales & Marketing', 'Technology'] # Define the education options education_options = ["Bachelor's", "Master's & above", "Below Secondary"] # Define the gender options gender_options = ['Male', 'Female'] # Define the awards won options awards_won_options = ['No', 'Yes'] # Define the maximum training score max_training_score = 100 # Define the maximum number of trainings max_trainings = 10 # Define the minimum and maximum age min_age, max_age = 18, 60 # Define the minimum and maximum length of service min_service_length, max_service_length = 0, 20 # Define the minimum and maximum previous year rating min_prev_year_rating, max_prev_year_rating = 1, 5 # Define the input components using Streamlit department = st.selectbox('---> Department', department_options) education = st.selectbox('---> Education', education_options) gender = st.radio('---> Gender', gender_options) no_of_trainings = st.number_input('---> Number of Trainings', min_value=1, max_value=max_trainings, value=1) age = st.slider('---> Age', min_value=min_age, max_value=max_age) previous_year_rating = st.slider('---> Previous Year Rating', min_value=min_prev_year_rating, max_value=max_prev_year_rating) length_of_service = st.number_input('---> Length of Service', min_value=min_service_length, max_value=max_service_length, value=0) awards_won = st.selectbox('---> Awards Won?', awards_won_options) avg_training_score = st.number_input('---> Average Training Score', max_value=max_training_score) department_encoding = {'Analytics':0, 'Finance':1, 'HR':2, 'Legal':3, 'Operations':4, 'Procurement':5, 'R&D':6, 'Sales & Marketing':7, 'Technology':8} education_encoding = {"Bachelor's":2, "Master's & above":3, "Below Secondary":1} gender_encoding = {'Male':1, 'Female':0} awards_won_encoding = {'No':0, 'Yes':1} sum_metric = awards_won_encoding[awards_won] + previous_year_rating total_score = avg_training_score * no_of_trainings inputs_to_model = np.array([(department_encoding[department], education_encoding[education], gender_encoding[gender], no_of_trainings, age, previous_year_rating, length_of_service, awards_won_encoding[awards_won], avg_training_score, sum_metric, total_score)]) final_inputs = scaling.transform(inputs_to_model) # Print the user inputs if st.button('Submit'): # st.write('Department:', department) # st.write('Education:', education) # st.write('Gender:', gender) # st.write('Number of Trainings:', no_of_trainings) # st.write('Age:', age) # st.write('Previous Year Rating:', previous_year_rating) # st.write('Length of Service:', length_of_service) # st.write('KPIs Met >80%:', kpis_met) # st.write('Awards Won?:', awards_won) # st.write('Average Training Score:', avg_training_score) # st.write('sum metric', sum_metric) # st.write('total score', total_score) # st.write('model inputs', inputs_to_model) # st.write('final model inputs', final_inputs) prediction = model.predict(final_inputs) if prediction[0] == 1: st.header('The Employee should get Promotion') else: st.header('The Employee should not get promotion')