-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
87 lines (51 loc) · 2.6 KB
/
app.py
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
import numpy as np
import pickle
import pandas as pd
import streamlit as st
from PIL import Image
pickle_in = open("RF.pkl","rb")
classifier=pickle.load(pickle_in)
def welcome():
return "Welcome All"
def predict_attrition(Age,OverTime_Yes,MonthlyIncome,TotalWorkingYears,DailyRate,HourlyRate,MonthlyRate,YearsAtCompany):
prediction=classifier.predict([[Age,OverTime_Yes,MonthlyIncome,TotalWorkingYears,DailyRate,HourlyRate,MonthlyRate,YearsAtCompany]])
print(prediction)
return prediction
def main():
st.set_page_config(
page_title="Predicting Employee Attrition",
layout="wide",
)
image = Image.open('Banner.png')
st.image(image)
st.title("Predicting Employee Attrition")
html_temp = """
<div style="background-color:tomato;padding:0px">
<h3 style="color:white;text-align:center;">Streamlit Predicting Employee Attrition ML Web App </h3>
</div>
"""
st.markdown(
'Our app gives the best prediction about the attrition.')
st.markdown(
'Among all the 3 various Algorithms **Random Forest** has the best accuracy with 84.6%.')
st.markdown(html_temp,unsafe_allow_html=True)
Age = st.text_input("Age",placeholder="Enter the Age of Employee :")
OverTime_Yes = st.text_input("OverTime_Yes",placeholder="If the Employee Works Overtime (1 or 0): ")
MonthlyIncome = st.text_input("MonthlyIncome",placeholder="Enter the Monthly Income of the Employee : ")
TotalWorkingYears = st.text_input("TotalWorkingYears",placeholder="Enter the total Working Years of the Employee : ")
DailyRate = st.text_input("DailyRate",placeholder="Enter the Daily Working rate of the Employee :")
HourlyRate = st.text_input("HourlyRate",placeholder="Enter the Hourly Working Rate of the Employee :")
MonthlyRate = st.text_input("MonthlyRate",placeholder="Enter the Monthly Working Rate of the Employee :")
YearsAtCompany = st.text_input("YearsAtCompany",placeholder="Enter the amonut of years employee worked at the Company : ")
result=""
if st.button("Predict"):
result=predict_attrition(Age,OverTime_Yes,MonthlyIncome,TotalWorkingYears,DailyRate,HourlyRate,MonthlyRate,YearsAtCompany)
if result == '1':
st.success('Employee is Attrinated')
else:
st.success('Employee is Not Attrinated')
if st.button("Click here to get Dataset"):
with open('WA_Fn-UseC_-HR-Employee-Attrition.csv') as f:
st.download_button('Download CSV', f, "WA_Fn-UseC_-HR-Employee-Attrition.csv")
if __name__=='__main__':
main()