Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Visualizing Employee Diversity Using Treemaps 1/34 Vi ali ing Emplo ee Di er i U ing Treemap Plea e e he - a da d d e da e. The p rpo e of hi a ignmen i o gi e o prac ice orking i h rec r i e da a r c...

1 answer below »
Visualizing Employee Diversity Using Treemaps
1/34
Vi ali ing Emplo ee Di er i U ing
Treemap
Plea e e he - a da d d e da e.
The p rpo e of hi a ignmen i o gi e o prac ice orking i h rec r i e da a r c re and ri ing
ec r i e f nc ion .
Y k al e hi a ig e .
In rod c ion
Some of he mo l cra i e en r -le el job in he U.S. are a echnolog companie in Silicon Valle . In re-
cen ear , grea er a en ion ha been paid o he her all people ho po e he kill , regardle of gen-
der or race, ha e an eq al oppor ni in being hired for he e ech job . The Ne York Time call hi
a e of affair Silicon Valle di er i problem, hile The G ardian refe
ed o Silicon Valle a Segre-
ga ed Valle in one ar icle. The lack of di er i in Silicon Valle ech companie ha pro en
ornl
per i en and ma ha e a n mber of ca e .
A hi q e ion ha recei ed grea er a en ion, re earcher and polic maker ha e beg n o collec da a o
e amine he c
en a e of affair more q an i a i el . For e ample, he U.S. Eq al Emplo men Oppor-
ni Commi ion (EEOC) collec ed emplo men di er i da a from a n mber of companie a EEO-1
Repor . Thi da a ho ed ha orkforce di er i a Silicon Valle ech firm a q i e differen han a
non- ech firm in Silicon Valle .
The da a cience i e Kaggle p bli hed da a from 22 Silicon Valle companie EEO-1 repor , enabling
an one o in e iga e he di er i of he e companie orkforce . Thi par ic lar da a e a collec ed
Re eal from The Cen er for In e iga i e Repor ing and relea ed nder an ODbl licen e.
While hi da a i modera el in ere ing a a pread hee , i ake ome caref l d o ge a en e of he
di er i a a par ic lar compan . Ra her han ing a pread hee , he mmar da a can be repre en ed
hierarchicall a a ee, here each b-di i ion i a node in he ree. For e ample, belo e ho he
n mber of emplo ee ho iden if a male and female a each of he 22 companie in he da a e . Thi ree
epre en j a par of he da a ( mming o er all race and all job ca egorie ). Each node con ain he
co n of emplo ee mmed acro i children node . For e ample, he roo node con ain XXXXXXXXXXem-
plo ee , hich i he m of he n mber of emplo ee a he 22 differen companie . 23andMe ha 297
emplo ee , 148 of hom iden if a male and 149 of hom iden if a female.
354964

23andMe: 297

male: 148

female: 149

Adobe: 7162

male: 4859

female: 2303

Ai bnb: 1917

male: 1095

female: 822

Apple: 77192

XXXXXXXXXXDue: Wednesday, December 2nd at 23:59.
11/24/2019
2/34

















































































































































│ ├──male: 53456
│ │
│ └──female: 23736
│
├──Cisco: 37526
│ │
│ ├──male: 27681
│ │
│ └──female: 9845
│
├──eBay: 6611
│ │
│ ├──male: 4238
│ │
│ └──female: 2373
│
├──Facebook: 11241
│ │
│ ├──male: 7676
│ │
│ └──female: 3565
│
├──Google: 46760
│ │
│ ├──male: 33120
│ │
│ └──female: 13640
│
├──HP Inc.: 13613
│ │
│ ├──male: 9393
│ │
│ └──female: 4220
│
├──HPE: 51989
│ │
│ ├──male: 34794
│ │
│ └──female: 17195
│
├──Intel: 54135
│ │
│ ├──male: 40084
│ │
│ └──female: 14051
│
├──Intuit: 5911
│ │
│ ├──male: 3373
│ │
│ └──female: 2538
│
├──LinkedIn: 6655
│ │
│ ├──male: 3978
│ │
│ └──female: 2677
│
├──Lyft: 1433
│ │
│ ├──male: 824
│ │
│ └──female: 609
│
├──MobileIron: 506
│ │
│ ├──male: 350
│ │
│ └──female: 156
│
├──Nvidia: 5348
│ │
│
11/24/2019
3/34
male: 4429

female: 919

Pin e e : 944

male: 537

female: 407

Sale fo ce: 14716

male: 10019

female: 4697

Sq a e: 1711

male: 1119

female: 592

T i e : 2952

male: 1908

female: 1044

Ube : 5885

male: 4149

female: 1736

Vie : 460

male: 382

female: 78
Each node i labeled b he par ic lar b-di i ion (e.g., male or female). No e ha e added a roo node
i h no label o ie he ca egorie oge her in o a ingle ree.
While hi ree repre en a ion help o make compari on , once e add in he o her fac or (job i le
and race), he da a ill be liced in ch a a ha e ill lack an in i i e en e of he rela i e di er i a
he differen companie . I o ld be m ch be er o ee a i al repre en a ion of he da a, hich i he
ole informa ion i ali a ion pla in comp ing and in da a cience.
Ho can e i ali e hi informa ion in an effec i e a ? We can e Treemap , hich are an e cellen
ool for i ali ing hierarchical da a. Here, for e ample, i a reemap of gender di er i acro he 22
companie :
11/24/2019
4/34
Treemap of gender di er i acro companie
Looking a he da a in hi form, e can immedia el ee he propor ion of male and female a each com-
pan , a ell a ho differen Silicon Valle ech companie compare o each o her in erm of gender di-
er i . The reemap al o i ali e he rela i e i e of he orkforce a each compan
Answered Same Day Nov 25, 2021

Solution

Kshitij answered on Nov 30 2021
137 Votes
# CS121: PA 7 - Diversity Treemap
#
# Code for constructing a treemap.
import argparse
import pandas as pd
import sys
import tree
import drawing
import click
###############
# #
# Your code #
# #
###############
def load_diversity_data(filename, debug=False):
'''
Load Silicon Valley diversity data and print summary
Inputs:
filename: (string) the name pf the file with the data
Returns: a pandas dataframe
'''
data = pd.read_csv(filename)
### Add print statements here (if debug is True)
if (debug == True):
print('Diversity data comes from the following {} companies:'.format(len(data['company'].value_counts())))
companies_ = list(data['company'].value_counts().index)
companies_.sort()
print(', '.join(companies_))
print()
print('The data includes {} employees'.format(sum(data['count'])))
print()
race_ = data.groupby('race').sum()['count']
for race in list(race_.index):
print(' ', race, ' : ', race_[race])
print()
print('gender')
gender_ = data.groupby('gender').sum()['count']
print(' male: {}'.format(gender_['male']))
print(' female: {}'.format(gender_['female']))
print()
print('race')
print('job_category')
job_ = data.groupby('job_category').sum()['count']
for job in list(job_.index):
print(' ', job, ' : ', job_[job])
return data
def compute_internal_counts(t):
'''
Assign a count to the interior nodes. The count of the leaves
should already be set. The count of an internal node is the sum
of the counts of its children.
Inputs:
t (Tree): a tree
Returns:
The input tree t should be modified so that every internal node's
count is set to be the sum of the counts of its children.
The return value will be:
- If the tree has no children: the value of the count attribute
- If the tree has children: the sum of the counts of the children
'''
### Replace 0 with the appropriate return value
if (t.num_children() == 0):
return t.count
t.count = sum([compute_internal_counts(child) for child in t.children])
return t.count
def compute_ve
ose_labels(t, prefix=None):
'''
Assign a ve
ose label to non-root nodes. Ve
ose labels contain the
full path to that node through the tree. For example, following the
path "Google" --> "female" --> "white" should create the ve
ose label
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here