Spaces:
Runtime error
Runtime error
import streamlit as st | |
import pandas as pd | |
import pickle | |
print(pd.__version__) | |
print(st.__version__) | |
print(pickle.format_version) | |
st.title("EMPLOYEE ATTRITION RISK PREDICTION") | |
st.write('Created by Hasbi Thaufik Oktodila') | |
# Step 1 - import saved model | |
model = pickle.load(open("model.pkl", "rb")) | |
st.write('Insert feature to predict') | |
# Step 2 - prepare input data for user | |
jobrole = st.selectbox(label='Job Role', options=['Sales Executive', 'Laboratory Technician', 'Research Scientist', 'Manufacturing Director', 'Healthcare Representative', | |
'Manager', 'Research Director', 'Sales Representative', 'Human Resources']) | |
maritalstatus = st.selectbox(label='Marital Status', options=['Single', 'Married', 'Divorced']) | |
overtime = st.selectbox(label='Frequently Overtime? (Yes = 1, No = 0)', options=[0, 1]) | |
businesstravel = st.selectbox(label='Frequently Have Business Travel? (1 = Non Travel, 2 = Rarely, 3 = Frequently)', options=[1, 2, 3]) | |
gender = st.selectbox(label='Gender (Male = 1, Female = 2)', options=[1,2]) | |
hourlyrate = st.slider(label='Your Hourly Rate', min_value=30, max_value=100, step=1) | |
dailyrate = st.slider(label='Your Daily Rate', min_value=100, max_value=2000) | |
percentsalaryhike = st.slider(label='Your Percent Salary Hike', min_value=10, max_value=30, step=1) | |
age = st.slider(label='Your Age', min_value=18, max_value=60, step=1) | |
distancefromhome = st.slider(label='Your Office Distance From Home', min_value=1, max_value=30, step=1) | |
# convert into dataframe | |
data = pd.DataFrame({'jobrole': [jobrole], | |
'maritalstatus': [maritalstatus], | |
'overtime': [overtime], | |
'businesstravel':[businesstravel], | |
'gender': [gender], | |
'hourlyrate': [hourlyrate], | |
'dailyrate': [dailyrate], | |
'percentsalaryhike': [percentsalaryhike], | |
'age': [age], | |
'distancefromhome': [distancefromhome] | |
}) | |
st.write(data) | |
# model predict | |
clas = model.predict(data).tolist()[0] | |
# interpretation | |
st.write('Attrition Risk: ') | |
if clas == 0: | |
st.text('Safe') | |
else: | |
st.text('Risky') | |