Skip to content

Commit

Permalink
Merge pull request #23 from HazelJJJ/main
Browse files Browse the repository at this point in the history
update readme, use updated app.py and change file location to src
  • Loading branch information
ChuckHo777 authored Jan 23, 2021
2 parents bf37957 + f222bc4 commit 5c67877
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@
## Link to the deployed dashboard


## Welcome!
Welcome to our dashboard!

Thank you for visiting the Attrtion app project repository.

This document(the README file) is going to offer you some information about the project. We are very excited to show you what we have here!

## What are we doing?

### The problem

Companies usually spend a large amount of money on training new employees every year. Whenever there is a turnover, it is costly to go through the hiring and training process. Therefore, employee loyalty is one the important things that management team should draw attention to. It is very useful to uncover the factors contribute to employee attrition.

### The solution

To address this challenge, we propose building a data visualization app that offers the management team to visually explore the dataset of employee attrition to identify common factors. Our app will show whether the employee choose to attrite and allow users to filter different variables in order to better explore and compare the factors that lead to attrition.

## Motivation

We designed this app based on the IBM HR Analytics Employee Attrition & Performance. Our target audience is the IBM Management Team. By navigating through the dashboard, it can help the management team observe the key contributors for attrition with guidance of a direction to improve employee retention and prevent attrition in the future.

## Description of app & sketch

Expand Down
27 changes: 8 additions & 19 deletions app.py → src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import pandas as pd
import dash_bootstrap_components as dbc

#updated data path

df = pd.read_csv(r"data/Processed/HR_employee_Attrition_editted.csv")
###Convert variables to categoriccal and reordering by label.
df['EnvironmentSatisfaction'] = df['EnvironmentSatisfaction'].astype('category').cat.rename_categories(["Bad", "Good", "Better", "Best"])
df['WorkLifeBalance']=df['WorkLifeBalance'].astype('category').cat.rename_categories(["Low", "Medium", "High", "Very High"])
df['EnvironmentSatisfaction'] = df['EnvironmentSatisfaction'].astype('category').cat.rename_categories(["1 - Bad", "2 - Good", "3 - Better", "4 - Best"])
df['WorkLifeBalance']=df['WorkLifeBalance'].astype('category').cat.rename_categories(["1 - Low", "2 - Medium", "3 - High", "4 - Very High"])
df["Department"]=df["Department"].astype('category')
df["BusinessTravel"]=df["BusinessTravel"].astype('category')
df['BusinessTravel'] = df['BusinessTravel'].cat.rename_categories(["No Travel", "Travel Frequently", "Travel Rarely"])
#df['BusinessTravel'] = df['BusinessTravel'].cat.reorder_categories(["Travel Rarely", "Travel Frequently", "No Travel"], ordered=True)
df['BusinessTravel'] = df['BusinessTravel'].cat.rename_categories(["1 - No Travel", "3 - Travel Frequently", "2 - Travel Rarely"])

# Setup app and layout/frontend
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
Expand All @@ -30,14 +29,6 @@
options=[
{'label': col, 'value': col} for col in list(set(df.Department.tolist()))],
placeholder='Select a department'),

# 'Job Role',
# dcc.Dropdown(
# id='job-widget',
# value='Sales Representative',
# options=[
# {'label': col, 'value': col} for col in set(df.JobRole.tolist())],
# placeholder='Select a job role'),

'Gender',
dcc.Dropdown(
Expand Down Expand Up @@ -65,13 +56,11 @@
id='scatter',
style={'border-width': '0', 'width': '200%', 'height': '800px'}),
)])])
#style={"height": "1000vh"}

# Set up callbacks/backend
@app.callback(
Output('scatter', 'srcDoc'),
Input('depart-widget', 'value'),
#Input('job-widget', 'value'),
Input('gender-widget', 'value'),
Input('age_slider', 'value'))

Expand All @@ -87,22 +76,22 @@ def plot_altair(depart,gender, age=18):
chart_worklife = alt.Chart(
df[(df['Department']==depart) &(df['Gender']==gender)&(df['Age']>=age[0])&(df['Age']<=age[1])],
title='Work Life Balance').mark_bar().encode(
y=alt.Y('WorkLifeBalance:O', title='', scale=alt.Scale(domain=["Low", "Medium", "High", "Very High"])),
y=alt.Y('WorkLifeBalance:O', title=''), #scale=alt.Scale(domain=["Low", "Medium", "High", "Very High"])
x=alt.X('count()', stack = 'normalize', axis=alt.Axis(format='%'), title = 'Proportion'),
color = 'Attrition'
).properties(height=200, width=250)

chart_travel = alt.Chart(
df[(df['Department']==depart) &(df['Gender']==gender)&(df['Age']>=age[0])&(df['Age']<=age[1])],
title='Business Travel Frequency').mark_bar().encode(
y=alt.Y("BusinessTravel", title="", scale=alt.Scale(domain=["No Travel", "Travel Rarely", "Travel Frequently"]),
y=alt.Y("BusinessTravel", title=""),
x=alt.X('count()', stack="normalize", axis=alt.Axis(format='%'), title='Proportion'),
color = "Attrition").properties(height=200, width=250))
color = "Attrition").properties(height=200, width=250)

chart_environment = alt.Chart(
df[(df['Department']==depart) & (df['Gender']==gender)&(df['Age']>=age[0])&(df['Age']<=age[1])],
title='Environment Satisfaction').mark_bar().encode(
y=alt.Y('EnvironmentSatisfaction', title='', scale=alt.Scale(domain=["Bad", "Good", "Better", "Best"])),
y=alt.Y('EnvironmentSatisfaction', title=''),
x=alt.X('count()', stack = 'normalize', axis=alt.Axis(format='%'), title = 'Proportion'),
color='Attrition').properties(height=200, width=250)

Expand Down

0 comments on commit 5c67877

Please sign in to comment.