Spaces:
Runtime error
Runtime error
Commit
·
64a2aa9
1
Parent(s):
749af93
app
Browse files
app.py
CHANGED
@@ -1,22 +1,42 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
title = "Employee Experience"
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
title=None,
|
15 |
-
examples=[],
|
16 |
-
description="Data correlation and pattern visualization!",
|
17 |
-
)
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from sklearn.preprocessing import LabelEncoder
|
4 |
+
from sklearn.feature_selection import mutual_info_classif
|
5 |
+
from sklearn.feature_selection import chi2
|
6 |
+
from sklearn.linear_model import LinearRegression
|
7 |
+
import numpy as np
|
8 |
|
|
|
9 |
|
10 |
+
def update(name):
|
11 |
+
df = pd.read_csv('emp_experience_data.csv')
|
12 |
+
pd.options.display.max_columns = 25
|
13 |
+
data_encoded = df.copy(deep=True)
|
14 |
+
categorical_column = ['Attrition', 'Gender', 'BusinessTravel', 'Education', 'EmployeeExperience', 'EmployeeFeedbackSentiments', 'Designation',
|
15 |
+
'SalarySatisfaction', 'HealthBenefitsSatisfaction', 'UHGDiscountProgramUsage', 'HealthConscious', 'CareerPathSatisfaction', 'Region']
|
16 |
+
label_encoding = LabelEncoder()
|
17 |
+
for col in categorical_column:
|
18 |
+
data_encoded[col] = label_encoding.fit_transform(data_encoded[col])
|
19 |
|
20 |
+
data_selected = data_encoded[['EmployeeExperience', 'HealthBenefitsSatisfaction', 'SalarySatisfaction', 'Designation', 'HealthConscious',
|
21 |
+
'EmployeeFeedbackSentiments', 'Education', 'Gender', 'HoursOfTrainingAttendedLastYear', 'InternalJobMovement', 'Attrition']]
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
input_data = data_selected.drop(['Attrition'], axis=1)
|
24 |
+
target_data = data_selected[['Attrition']]
|
25 |
+
input_data = data_selected[0:100]
|
26 |
+
validation_data = data_selected[100:198]
|
27 |
+
validation_input_data = validation_data.drop(['Attrition'], axis=1)
|
28 |
+
validation_target_data = validation_data[['Attrition']]
|
29 |
+
reg = LinearRegression().fit(validation_input_data, validation_target_data)
|
30 |
+
prediction_value = reg.predict(np.array([[2,2,1,3,1,2,0,1,40,1]]))
|
31 |
+
print(prediction_value)
|
32 |
+
return f"Prediction : , {prediction_value}!"
|
33 |
|
34 |
+
with gr.Blocks() as demo:
|
35 |
+
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
36 |
+
with gr.Row():
|
37 |
+
inp = gr.Textbox(placeholder="Enter Employee Experience Data")
|
38 |
+
out = gr.Textbox()
|
39 |
+
btn = gr.Button("Run")
|
40 |
+
btn.click(fn=update, inputs=inp, outputs=out)
|
41 |
+
|
42 |
+
demo.launch()
|