Parthebhan commited on
Commit
6e80622
·
verified ·
1 Parent(s): 88d8b40

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import gradio as gr
3
+
4
+ # Load the pickled model
5
+ with open('./xgb_waze.pickle', 'rb') as file:
6
+ model = pickle.load(file)
7
+
8
+ # Define the function for making predictions
9
+ def salifort(last_evaluation, number_project, tenure, work_accident, promotion_last_5years, salary, department_IT, department_RandD, department_accounting, department_hr, department_management, department_marketing, department_product_mng, department_sales, department_support, department_technical, overworked):
10
+ inputs = [[float(last_evaluation), float(number_project), float(tenure), float(work_accident), float(promotion_last_5years), float(salary), float(department_IT), float(department_RandD), float(department_accounting), float(department_hr), float(department_management), float(department_marketing), float(department_product_mng), float(department_sales), float(department_support), float(department_technical), float(overworked)]]
11
+ prediction = model.predict(inputs)
12
+ prediction_value = prediction[0]
13
+ if prediction_value == 0:
14
+ label_text = 'Employee would not leave the company 🟢'
15
+ else:
16
+ label_text = 'Employee will leave the company 🔴'
17
+ return label_text
18
+
19
+ # Create the Gradio interface
20
+ salifort_ga = gr.Interface(fn=salifort,
21
+ inputs = [
22
+ gr.Number(0, 1, label="last_evaluation: [0 1]"),
23
+ gr.Number(2, 7, label="number_project: [2 to 7]"),
24
+ gr.Number(2, 10, label="tenure: [2 to 10]"),
25
+ gr.Number(0, 1, label="work_accident: [0 1]"),
26
+ gr.Number(0, 1, label="promotion_last_5years: [0 1]"),
27
+ gr.Number(0, 2, label="salary: [0 1 2]"),
28
+ gr.Number(0, 1, label="department_IT: [0 1]"),
29
+ gr.Number(0, 1, label="department_RandD: [0 1]"),
30
+ gr.Number(0, 1, label="department_accounting: [0 1]"),
31
+ gr.Number(0, 1, label="department_hr: [0 1]"),
32
+ gr.Number(0, 1, label="department_management: [0 1]"),
33
+ gr.Number(0, 1, label="department_marketing: [0 1]"),
34
+ gr.Number(0, 1, label="department_product_mng: [0 1]"),
35
+ gr.Number(0, 1, label="department_sales: [0 1]"),
36
+ gr.Number(0, 1, label="department_support: [0 1]"),
37
+ gr.Number(0, 1, label="department_technical: [0 1]"),
38
+ gr.Number(0, 1, label="overworked: [0 1]")
39
+ ],
40
+ outputs = "text", title="Data-driven suggestions for HR - Salifort Motors - Employee Retention",
41
+ examples = [
42
+ [0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
43
+ [0, 3, 3, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
44
+ [0, 2, 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
45
+ [0, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1]
46
+ ],
47
+ description="Employee Retention Prediction Using Machine Learning",
48
+ theme='dark'
49
+ )
50
+
51
+ salifort_ga.launch(share=True)