Spaces:
Runtime error
Runtime error
File size: 1,343 Bytes
1571821 |
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 |
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import gradio as gr
plt.switch_backend('Agg')
pd.options.display.max_columns = 25
pd.options.display.max_rows = 300
def outbreak(plot_type):
df = pd.read_csv('emp_experience_data.csv')
data_encoded = df.copy(deep=True)
if plot_type == "Age Attrition":
fig = plt.figure()
positive_attrition_df = data_encoded.loc[data_encoded['Attrition'] == "Yes"]
plt.hist(positive_attrition_df['Age'], bins=np.arange(0,80,10), alpha=0.8, rwidth=0.9, color='blue')
plt.xlabel("Age")
plt.ylabel("Count")
plt.title("Age vs Attrition")
return fig
if plot_type == "Distance Attrition":
fig = plt.figure()
positive_attrition_df = data_encoded.loc[data_encoded['Attrition'] == "Yes"]
plt.hist(positive_attrition_df['DistanceFromHome'], bins=np.arange(0,80,10), alpha=0.8, rwidth=0.9, color='green')
plt.xlabel("Distance From Home")
plt.ylabel("Count")
plt.title("Distance vs Attrition")
return fig
inputs = [
gr.Dropdown(["Age Attrition", "Distance Attrition"], label="Plot Type")
]
outputs = gr.Plot()
demo = gr.Interface(fn=outbreak, inputs=inputs, outputs=outputs, examples=[], cache_examples=True)
if __name__ == "__main__":
demo.launch() |