File size: 3,686 Bytes
3c01ef0
 
 
 
4afe316
3c01ef0
 
 
d959f48
4afe316
 
 
 
 
3c01ef0
 
5cfe920
 
 
 
 
3c01ef0
 
4afe316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5cfe920
d959f48
 
 
 
 
 
 
4afe316
3c01ef0
 
 
4afe316
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
import pickle
import gradio as gr

# Load the pickled model
with open('./salifort_rf3.pickle', 'rb') as file:
    model = pickle.load(file)

# Define the function for making predictions
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):
    inputs = [['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']]
    prediction = model.predict(inputs) 
    prediction_value = prediction[0][0]
    if prediction_value == 0:
        label_text = 'employee would not leave the company'
    else:
        label_text = 'employee will leave the company'
    return label_text

# Create the Gradio interface
salifort_ga = gr.Interface(fn=salifort, 
                               inputs = [
                                            gr.Number(0, 1, label="last_evaluation: [0 1]"),
                                            gr.Number(2, 7, label="number_project: [2 to 7]"),
                                            gr.Number(2, 10, label="tenure: [2 to 10]"),
                                            gr.Number(0, 1, label="work_accident: [0 1]"),
                                            gr.Number(0, 1, label="promotion_last_5years: [0 1]"),
                                            gr.Number(0, 2, label="salary: [0 1 2]"),
                                            gr.Number(0, 1, label="department_IT: [0 1]"),
                                            gr.Number(0, 1, label="department_RandD: [0 1]"),
                                            gr.Number(0, 1, label="department_accounting: [0 1]"),
                                            gr.Number(0, 1, label="department_hr: [0 1]"),
                                            gr.Number(0, 1, label="department_management: [0 1]"),
                                            gr.Number(0, 1, label="department_marketing: [0 1]"),
                                            gr.Number(0, 1, label="department_product_mng: [0 1]"),
                                            gr.Number(0, 1, label="department_sales: [0 1]"),
                                            gr.Number(0, 1, label="department_support: [0 1]"),
                                            gr.Number(0, 1, label="department_technical: [0 1]"),
                                            gr.Number(0, 1, label="overworked: [0 1]")
                                        ],
                               outputs  = "text", title="Data-driven suggestions for HR - Salifort Motors - Employee Retention", 
                               examples = [
                                        [0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
                                        [0, 3, 3, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
                                        [0, 2, 3, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
                                        [0, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1]
                                         ],
                               description="Employee Retention Prediction Using Machine Learning",
                               theme='dark'
                               )

salifort_ga.launch(share=True)