Spaces:
Runtime error
Runtime error
| 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() |