File size: 4,803 Bytes
4c1d41a
 
 
 
 
2ff9125
4c1d41a
 
 
4bfee9c
291b4bd
 
a252330
 
291b4bd
3aabd65
 
291b4bd
a252330
291b4bd
2ff9125
 
 
 
 
 
 
291b4bd
2ff9125
 
 
 
 
 
 
291b4bd
 
 
 
2ff9125
3aabd65
2ff9125
291b4bd
2ff9125
3aabd65
291b4bd
 
2ff9125
 
291b4bd
2ff9125
291b4bd
 
2ff9125
291b4bd
 
 
 
 
 
 
 
4c1d41a
 
 
 
 
 
a6efa8b
c89093f
8ef7cda
a6efa8b
c89093f
8ef7cda
 
7b813dc
4c1d41a
 
a252330
4c1d41a
485e424
1015725
2ff9125
3aabd65
1015725
 
8878f63
1015725
 
4c1d41a
 
 
7b813dc
4c1d41a
ff14f2e
 
 
 
4c1d41a
 
7b813dc
 
4c1d41a
 
 
 
 
 
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import gradio as gr
import pandas as pd
from joblib import load


def humands(Sex,Age,Married,Monthlyincome,TotalWorkingYears,DistanceFromHome,Overtime,YearsAtCompany,NumCompaniesWorked):
    model = load('modelo_entrenado.pkl')
    df = pd.DataFrame.from_dict(
        {
            "MonthlyIncome" : [Monthlyincome],
            "Age" : [Age],
            "TotalWorkingYears" : [TotalWorkingYears],
            "DailyRate" : [Monthlyincome*2/30],
            "HourlyRate" : [Monthlyincome*2/1640],
            "DistanceFromHome" : [DistanceFromHome],
            "OverTime_Yes" : [1 if Overtime else 0],
            "OverTime_No" : [1 if not Overtime else 0],
            "YearsAtCompany" : [YearsAtCompany],
            "MonthlyRate" : [Monthlyincome*2],
            "NumCompaniesWorked" : [NumCompaniesWorked],
            "PercentSalaryHike" : [15],
            "YearsInCurrentRole" : [YearsAtCompany-1],
            "YearsWithCurrManager" : [YearsAtCompany-1],
            "StockOptionLevel" : [1],
            "YearsSinceLastPromotion" : [YearsAtCompany-1],
            "JobSatisfaction" : [2],
            "JobLevel" : [3],
            "TrainingTimesLastYear" : [0],
            "EnvironmentSatisfaction" : [2],
            "WorkLifeBalance" : [2],
            "MaritalStatus_Single" : [1 if Married==0 else 0],
            "JobInvolvement" : [2],
            "RelationshipSatisfaction" : [Married+1],
            "Education" : [2],
            "BusinessTravel_Travel_Frequently" : [1 if Overtime else 0],
            "JobRole_Sales Representative" : [0],
            "EducationField_Medical" : [0],
            "Department_Sales" : [0],
            "JobRole_Laboratory Technician" : [0],
            "Department_Research & Development" : [1],
            "Gender_Female" : [1 if Sex==0 else 0],
            "MaritalStatus_Married" : [1 if Married==1 else 0],
            "JobRole_Sales Executive" : [0],
            "EducationField_Technical Degree" : [1],
            "Gender_Male" : [1 if Sex==1 else 0],
            "EducationField_Life Sciences" : [0],
            "BusinessTravel_Travel_Rarely" : [0],
            "MaritalStatus_Divorced" : [1 if Married==2 else 0],
            "JobRole_Research Scientist" : [1],
            "EducationField_Marketing" : [0],
            "PerformanceRating" : [3],
            "EducationField_Other" : [0],
            "JobRole_Human Resources" : [0],
            "BusinessTravel_Non-Travel" : [1 if not Overtime else 0],
            "Department_Human Resources" : [0],
            "JobRole_Manufacturing Director" : [0],
            "JobRole_Healthcare Representative" : [0],
            "EducationField_Human Resources" : [0],
            "JobRole_Manager" : [0],
            "JobRole_Research Director" : [0],
            
            
                                 
        }
    )
         
    pred = model.predict(df)[0]

    if pred == "Yes":
        predicted1="Estamos ante un trabajador con alto nivel de desgaste del trabajo. Habría que plantearse alguna acción."
        predicted2="stressed_image.jpg"
    else:
        predicted1="Estamos ante un trabajador con un nivel bajo de desgaste del trabajo. Se ha de seguir así."
        predicted2="ok_image2.jpg"
    return [predicted1,predicted2]
   
    
iface = gr.Interface(
    humands,
    [
        gr.Radio(["Mujer","Hombre"],type = "index",label="Sexo"),
        gr.inputs.Slider(18,70,1,label="Edad del trabajador"),
        gr.Radio(["Soltero","Casado","Divorciado"],type = "index",label="Esstado civil:"),
        gr.inputs.Slider(1000,20000,1,label="Ingresos mensuales del trabajador"),
        gr.inputs.Slider(0,40,1,label="Total de años trabajados del trabajador"),
        gr.inputs.Slider(0,100,1,label="Distancia del trabajo al domicilio en Km"),
        gr.Checkbox(label="¿Realiza horas extras habitualmente?"),
        gr.inputs.Slider(0,40,1,label="Años del trabajador en la empresa"),
        gr.inputs.Slider(0,40,1,label="Numero de empresas en las que ha estado el trabajador"),
        
     ],

    ["text",gr.Image(type='file')],
    examples=[
        ["Mujer",33,"Soltero",2917,9,1,False,9,1],
        ["Hombre",42,"Casado",3111,16,5,False,7,3],
        ["Hombre",50,"Divorciado",1732,20,50,True,3,3],
        ["Mujer",25,"Soltero",2556,6,58,True,2,4],
    ],
    interpretation="default",
    title = 'HUMANDS: Inteligencia artificial para empleados',
    description = 'Uno de los motivos por los que las organizaciones pierden a sus empleados es la insatisfacción laboral, por ello, nuestro objetivo es predecir el verdadero nivel de desgaste de los empleados dentro de una organización mediante Inteligencia Artificial. Para saber más: https://saturdays.ai/2021/12/31/inteligencia-artificial-empleados/',
    theme = 'peach'
)


   
iface.launch()