hidevscommunity commited on
Commit
711c5ae
·
1 Parent(s): c12297c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +113 -0
app.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pickle
4
+ import streamlit.components.v1 as components
5
+
6
+ # Load the pickled model
7
+ def load_model():
8
+ return pickle.load(open('Employee_Attrition_ra.pkl', 'rb'))
9
+
10
+ # Function for model prediction
11
+ def model_prediction(model, features):
12
+ predicted = str(model.predict(features)[0])
13
+ return predicted
14
+
15
+ def app_design():
16
+ # Add input fields for High, Open, and Low values
17
+ image = '13.png'
18
+ st.image(image, use_column_width=True)
19
+
20
+ st.subheader("Enter the following values:")
21
+
22
+ Age = st.number_input("Age")
23
+ BusinessTravel = st.number_input("Business Travel")
24
+ DailyRate = st.number_input("Daily Rate")
25
+ Department = st.number_input("Department")
26
+ DistanceFromHome = st.number_input("Distance From Home")
27
+ Education = st.number_input("Education")
28
+ EducationField = st.number_input("Education Field")
29
+ EmployeeCount = st.number_input("Employee Count")
30
+ EmployeeNumber = st.number_input("Employee Number")
31
+ EnvironmentSatisfaction = st.number_input("Environment Satisfaction")
32
+ Gender = st.selectbox('Gender',('Male','Female'))
33
+ if Gender == 'Male':
34
+ Gender = 0
35
+ elif Gender == 'Female':
36
+ Gender = 1
37
+ HourlyRate = st.number_input("Hourly Rate")
38
+ JobInvolvement = st.number_input("Job Involvement")
39
+ JobLevel = st.number_input("Job Level")
40
+ JobRole = st.number_input("Job Role")
41
+ JobSatisfaction = st.number_input("JobSatisfaction")
42
+ MaritalStatus = st.number_input("Marital Status")
43
+ MonthlyIncome = st.number_input("Monthly Income")
44
+ MonthlyRate = st.number_input("Monthly Rate")
45
+ NumCompaniesWorked = st.number_input("Number of Companies in you worked")
46
+ Over18 = st.number_input("Over 18 age")
47
+ OverTime = st.number_input("Overtime hours")
48
+ PercentSalaryHike = st.number_input("Percent Salary Hike")
49
+ PerformanceRating = st.number_input("Performance Rating")
50
+ RelationshipSatisfaction = st.number_input("Relationship Satisfaction")
51
+ StandardHours = st.number_input("Standard Hours")
52
+ StockOptionLevel = st.number_input("Stock Option Level")
53
+ TotalWorkingYears = st.number_input("Total Working Years")
54
+ TrainingTimesLastYear = st.number_input("Training Times Last Year")
55
+ WorkLifeBalance = st.number_input("Work Life Balance")
56
+ YearsAtCompany = st.number_input("Years At Company")
57
+ YearsInCurrentRole = st.number_input("Years In Current Role")
58
+ YearsSinceLastPromotion = st.number_input("Years Since Last Promotion")
59
+ YearsWithCurrManager = st.number_input("Years With Current Manager")
60
+
61
+
62
+ # Create a feature list from the user inputs
63
+ features = [[Age,BusinessTravel,DailyRate,Department,DistanceFromHome,Education,EducationField,EmployeeCount,EmployeeNumber,EnvironmentSatisfaction,Gender,HourlyRate,JobInvolvement,JobLevel,JobRole,JobSatisfaction,MaritalStatus,MonthlyIncome,MonthlyRate,NumCompaniesWorked,Over18,OverTime,PercentSalaryHike,PerformanceRating,RelationshipSatisfaction,StandardHours,StockOptionLevel,TotalWorkingYears,TrainingTimesLastYear,WorkLifeBalance,YearsAtCompany,YearsInCurrentRole,YearsSinceLastPromotion,YearsWithCurrManager]]
64
+
65
+ # Load the model
66
+ model = load_model()
67
+
68
+ # Make a prediction when the user clicks the "Predict" button
69
+ if st.button('Predict Attrition'):
70
+ predicted_value = model_prediction(model, features)
71
+ if predicted_value == 0:
72
+ st.success(f"The Employee will leave the company")
73
+ else:
74
+ st.success(f"The Employee will not leave the company")
75
+
76
+
77
+ def about_hidevs():
78
+
79
+ components.html("""
80
+ <div>
81
+ <h4>🚀 Unlock Your Dream Job with HiDevs Community!</h4>
82
+ <p class="subtitle">🔍 Seeking the perfect job? HiDevs Community is your gateway to career success in the tech industry. Explore free expert courses, job-seeking support, and career transformation tips.</p>
83
+ <p class="subtitle">💼 We offer an upskill program in <b>Gen AI, Data Science, Machine Learning</b>, and assist startups in adopting <b>Gen AI</b> at minimal development costs.</p>
84
+ <p class="subtitle">🆓 Best of all, everything we offer is <b>completely free</b>! We are dedicated to helping society.</p>
85
+ <p class="subtitle">Book free of cost 1:1 mentorship on any topic of your choice — <a class="link" href="https://topmate.io/deepakchawla1307">topmate</a></p>
86
+ <p class="subtitle">✨ We dedicate over 30 minutes to each applicant’s resume, LinkedIn profile, mock interview, and upskill program. If you’d like our guidance, check out our services <a class="link" href="https://hidevscommunity.wixsite.com/hidevs">here</a></p>
87
+ <p class="subtitle">💡 Join us now, and turbocharge your career!</p>
88
+ <p class="subtitle"><a class="link" href="https://hidevscommunity.wixsite.com/hidevs" target="__blank">Website</a>
89
+ <a class="link" href="https://www.youtube.com/@HidevsCommunity1307/" target="__blank">YouTube</a>
90
+ <a class="link" href="https://www.instagram.com/hidevs_community/" target="__blank">Instagram</a>
91
+ <a class="link" href="https://medium.com/@hidevscommunity" target="__blank">Medium</a>
92
+ <a class="link" href="https://www.linkedin.com/company/hidevs-community/" target="__blank">LinkedIn</a>
93
+ <a class="link" href="https://github.com/hidevscommunity" target="__blank">GitHub</a></p>
94
+ </div>
95
+ """,
96
+ height=600)
97
+
98
+ def main():
99
+
100
+ # Set the app title and add your website name and logo
101
+ st.set_page_config(
102
+ page_title="Employee Attrition Prediction",
103
+ page_icon=":chart_with_upwards_trend:",
104
+ )
105
+
106
+ st.title("Welcome to our Employee Attrition Prediction App!")
107
+
108
+ app_design()
109
+ st.header("About HiDevs Community")
110
+ about_hidevs()
111
+
112
+ if __name__ == '__main__':
113
+ main()