stefania11 commited on
Commit
5f6b497
·
1 Parent(s): 285f890

update app file

Browse files
Files changed (1) hide show
  1. app.py +59 -59
app.py CHANGED
@@ -350,65 +350,65 @@ with gr.Blocks(css=css) as demo:
350
  )
351
  # clear_btn.click(fn=lambda value: gr.update(value=""), inputs=clear_btn, outputs=translated_output)
352
 
353
- gr.Markdown("""
354
- ## 4. Plot the generated code ☕️
355
- Inference time is about ~20-30 seconds, when it's your turn 😬
356
- """
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")
402
- ]
403
- outputs = gr.Plot()
404
-
405
- demo2 = gr.Interface(
406
- fn = outbreak,
407
- inputs = inputs,
408
- outputs = outputs,
409
- title="Employee-Experience: Data Correlation and Pattern Visualization",
410
- allow_flagging=False
411
- )
412
 
413
 
414
  gr.Markdown("""
 
350
  )
351
  # clear_btn.click(fn=lambda value: gr.update(value=""), inputs=clear_btn, outputs=translated_output)
352
 
353
+ # gr.Markdown("""
354
+ # ## 4. Plot the generated code ☕️
355
+ # Inference time is about ~20-30 seconds, when it's your turn 😬
356
+ # """
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")
402
+ # ]
403
+ # outputs = gr.Plot()
404
+
405
+ # demo2 = gr.Interface(
406
+ # fn = outbreak,
407
+ # inputs = inputs,
408
+ # outputs = outputs,
409
+ # title="Employee-Experience: Data Correlation and Pattern Visualization",
410
+ # allow_flagging=False
411
+ # )
412
 
413
 
414
  gr.Markdown("""