stefania11 commited on
Commit
d79b9b1
Β·
1 Parent(s): 4d2f5ac

update app file

Browse files
Files changed (1) hide show
  1. app.py +40 -40
app.py CHANGED
@@ -79,45 +79,7 @@ def translate(audio):
79
  tr_flag = flag.flag(transcription.language)
80
  return tr_flag, transcription.text, translation.text
81
 
82
- def outbreak(plot_type):
83
- df = pd.read_csv('emp_experience_data.csv')
84
- data_encoded = df.copy(deep=True)
85
- categorical_column = ['Attrition', 'Gender', 'BusinessTravel', 'Education', 'EmployeeExperience', 'EmployeeFeedbackSentiments', 'Designation',
86
- 'SalarySatisfaction', 'HealthBenefitsSatisfaction', 'UHGDiscountProgramUsage', 'HealthConscious', 'CareerPathSatisfaction', 'Region']
87
- label_encoding = LabelEncoder()
88
- for col in categorical_column:
89
- data_encoded[col] = label_encoding.fit_transform(data_encoded[col])
90
-
91
- if plot_type == "Find Data Correlation":
92
- fig = plt.figure()
93
- data_correlation = data_encoded.corr()
94
- sns.heatmap(data_correlation, xticklabels = data_correlation.columns, yticklabels = data_correlation.columns)
95
- return fig
96
- if plot_type == "Filter Correlation Data":
97
- fig = plt.figure()
98
- filtered_df = df[['EmployeeExperience', 'EmployeeFeedbackSentiments', 'Age', 'SalarySatisfaction', 'BusinessTravel', 'HealthBenefitsSatisfaction']]
99
- correlation_filter_data = filtered_df.corr()
100
- sns.heatmap(correlation_filter_data, xticklabels = filtered_df.columns, yticklabels = filtered_df.columns)
101
- return fig
102
- if plot_type == "Age vs Attrition":
103
- fig = plt.figure()
104
- plt.hist(data_encoded['Age'], bins=np.arange(0,80,10), alpha=0.8, rwidth=0.9, color='red')
105
- plt.xlabel("Age")
106
- plt.ylabel("Count")
107
- plt.title("Age vs Attrition")
108
- return fig
109
- if plot_type == "Business Travel vs Attrition":
110
- fig = plt.figure()
111
- ax = sns.countplot(x="BusinessTravel", hue="Attrition", data=data_encoded)
112
- for p in ax.patches:
113
- ax.annotate('{}'.format(p.get_height()), (p.get_x(), p.get_height()+1))
114
- return fig
115
- if plot_type == "Employee Experience vs Attrition":
116
- fig = plt.figure()
117
- ax = sns.countplot(x="EmployeeExperience", hue="Attrition", data=data_encoded)
118
- for p in ax.patches:
119
- ax.annotate('{}'.format(p.get_height()), (p.get_x(), p.get_height()+1))
120
- return fig
121
  ### β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
122
 
123
  css = """
@@ -395,7 +357,45 @@ with gr.Blocks(css=css) as demo:
395
  )
396
  with gr.Column():
397
  with gr.Row():
398
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
 
400
  inputs = [
401
  gr.Dropdown(["Find Data Correlation", "Filter Correlation Data", "Business Travel vs Attrition", "Employee Experience vs Attrition", "Age vs Attrition",], label="Data Correlation and Visualization")
 
79
  tr_flag = flag.flag(transcription.language)
80
  return tr_flag, transcription.text, translation.text
81
 
82
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  ### β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
84
 
85
  css = """
 
357
  )
358
  with gr.Column():
359
  with gr.Row():
360
+ def outbreak(plot_type):
361
+ df = pd.read_csv('emp_experience_data.csv')
362
+ data_encoded = df.copy(deep=True)
363
+ categorical_column = ['Attrition', 'Gender', 'BusinessTravel', 'Education', 'EmployeeExperience', 'EmployeeFeedbackSentiments', 'Designation',
364
+ 'SalarySatisfaction', 'HealthBenefitsSatisfaction', 'UHGDiscountProgramUsage', 'HealthConscious', 'CareerPathSatisfaction', 'Region']
365
+ label_encoding = LabelEncoder()
366
+ for col in categorical_column:
367
+ data_encoded[col] = label_encoding.fit_transform(data_encoded[col])
368
+
369
+ if plot_type == "Find Data Correlation":
370
+ fig = plt.figure()
371
+ data_correlation = data_encoded.corr()
372
+ sns.heatmap(data_correlation, xticklabels = data_correlation.columns, yticklabels = data_correlation.columns)
373
+ return fig
374
+ if plot_type == "Filter Correlation Data":
375
+ fig = plt.figure()
376
+ filtered_df = df[['EmployeeExperience', 'EmployeeFeedbackSentiments', 'Age', 'SalarySatisfaction', 'BusinessTravel', 'HealthBenefitsSatisfaction']]
377
+ correlation_filter_data = filtered_df.corr()
378
+ sns.heatmap(correlation_filter_data, xticklabels = filtered_df.columns, yticklabels = filtered_df.columns)
379
+ return fig
380
+ if plot_type == "Age vs Attrition":
381
+ fig = plt.figure()
382
+ plt.hist(data_encoded['Age'], bins=np.arange(0,80,10), alpha=0.8, rwidth=0.9, color='red')
383
+ plt.xlabel("Age")
384
+ plt.ylabel("Count")
385
+ plt.title("Age vs Attrition")
386
+ return fig
387
+ if plot_type == "Business Travel vs Attrition":
388
+ fig = plt.figure()
389
+ ax = sns.countplot(x="BusinessTravel", hue="Attrition", data=data_encoded)
390
+ for p in ax.patches:
391
+ ax.annotate('{}'.format(p.get_height()), (p.get_x(), p.get_height()+1))
392
+ return fig
393
+ if plot_type == "Employee Experience vs Attrition":
394
+ fig = plt.figure()
395
+ ax = sns.countplot(x="EmployeeExperience", hue="Attrition", data=data_encoded)
396
+ for p in ax.patches:
397
+ ax.annotate('{}'.format(p.get_height()), (p.get_x(), p.get_height()+1))
398
+ return figure
399
 
400
  inputs = [
401
  gr.Dropdown(["Find Data Correlation", "Filter Correlation Data", "Business Travel vs Attrition", "Employee Experience vs Attrition", "Age vs Attrition",], label="Data Correlation and Visualization")