Spaces:
Build error
Build error
File size: 1,916 Bytes
b17d045 1bce424 b17d045 79ea815 b17d045 79ea815 1bce424 79ea815 b17d045 79ea815 b17d045 55501e5 b17d045 |
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 42 43 44 45 46 47 48 |
import gradio as gr
import pandas as pd
from sklearn.preprocessing import LabelEncoder
def data_description(desc_type):
df = pd.read_csv('emp_experience_data.csv')
pd.options.display.max_columns = 25
pd.options.display.max_rows = 10
data_encoded = df.copy(deep=True)
categorical_column = ['Attrition', 'Gender', 'BusinessTravel', 'Education', 'EmployeeExperience', 'EmployeeFeedbackSentiments', 'Designation',
'SalarySatisfaction', 'HealthBenefitsSatisfaction', 'UHGDiscountProgramUsage', 'HealthConscious', 'CareerPathSatisfaction', 'Region']
label_encoding = LabelEncoder()
if desc_type == "Display Data":
return df.head()
if desc_type == "Describe Data":
df_copy = df.copy(deep=True)
data_desc = df_copy.describe()
data_desc.insert(0, "Description", ["count", "mean", "std", "min", "25%", "50%", "75%", "max"], True)
return data_desc
if desc_type == "Display Encoding":
data = [["Feature", "Mapping"]]
for col in categorical_column:
data_encoded[col] = label_encoding.fit_transform(data_encoded[col])
le_name_mapping = dict(zip(label_encoding.classes_, label_encoding.transform(label_encoding.classes_)))
data.append([col, str(le_name_mapping)])
return data
if desc_type == "Display Encoded Data":
for col in categorical_column:
data_encoded[col] = label_encoding.fit_transform(data_encoded[col])
return data_encoded.head()
inputs = [
gr.Dropdown(["Display Data", "Describe Data", "Display Encoding", "Display Encoded Data"], label="Perform Data Actions")
]
outputs = [gr.DataFrame()]
demo = gr.Interface(
fn = data_description,
inputs = inputs,
outputs = outputs,
title="Employee-Experience: Data Description",
allow_flagging=False
)
if __name__ == "__main__":
demo.launch() |