Polyglot Unconference

This notebook holds a project conducting data analysis and visualization of the 2017 Polyglot Vancouver Un-Conference.

See the README in this repository for background information.

Session 05 - "Kotlin"

This was an introduction to the Kotlin programming language, that was both tightly controlled by the host and encouraging of questions. There were several people that had either pointed questions or some experience with Kotlin (and the language(s) that the questioners were experienced with), which led to a fairly egalitarian discussion... at least compared to some of the other sessions.

Python imports


In [1]:
# Imports

import sys
import pandas as pd
import csv

%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (20.0, 10.0)

In [2]:
# %load util.py
#!/usr/bin/python

# Util file to import in all of the notebooks to allow for easy code re-use


# Calculate Percent of Attendees that did not speak
def percent_silent(df):
    total = len(df)
    silent = 0
    for row in df.iteritems():
        if row[1] == 0:
            silent = silent + 1

    percent = {}
    percent['TOTAL'] = total
    percent['SILENT'] = silent
    percent['VERBOSE'] = total - silent
    return percent

# Calculate Percent of Attendees that left
def percent_left(df):
    total = len(df)
    left = 0
    for row in df.iteritems():
        if row[1] == 0:
            left = left + 1

    percent = {}
    percent['TOTAL'] = total
    percent['LEFT'] = left
    percent['STAYED'] = total - left
    return percent

# Calculate Percent of Attendees along gender
def percent_gender(df):
    total = len(df)
    female = 0
    for row in df.iteritems():
        if row[1] == 1:
            female = female + 1

    percent = {}
    percent['TOTAL'] = total
    percent['FEMALE'] = female
    percent['MALE'] = total - female
    return percent

# Calculate Percent of Talking points by
def percent_talking_gender(df):
    total = 0
    male = 0
    female = 0
    for talks, gender in df.itertuples(index=False):
        if talks > 0:
            total = total + 1
            if gender == 0:
                male = male + 1
            elif gender == 1:
                female = female + 1

    percent = {}
    percent['TOTAL'] = total
    percent['FEMALE'] = female
    percent['MALE'] = male
    return percent

Reading the Data


In [10]:
# Read
data = pd.read_csv('data/5_kotlin.csv')

# Display
data


Out[10]:
PERSON TALKS GENDER STAYED
0 H1 27 M Y
1 01 1 M Y
2 02 1 M Y
3 03 0 M Y
4 04 8 M Y
5 05 12 M Y
6 06 1 M N
7 07 5 M Y
8 08 1 M N
9 09 1 M Y
10 10 9 M Y
11 11 5 M Y
12 12 2 M Y
13 13 6 M Y
14 14 4 M Y
15 15 3 M Y
16 16 6 M Y
17 17 0 M Y
18 18 0 M Y
19 19 0 M Y
20 20 0 M N
21 21 0 M Y
22 22 0 M N
23 23 0 M N
24 24 0 F Y
25 25 2 M L
26 26 1 M L
27 27 1 M L

Sanitizing the Data

As we can see, some of our data is stored in a non-numerical format which makes it difficult to perform the maths upon.

Let's clean it up.


In [11]:
# Convert GENDER to Binary (sorry, i know...)

data.loc[data["GENDER"] == "M", "GENDER"] = 0
data.loc[data["GENDER"] == "F", "GENDER"] = 1

# Convert STAYED to 1 and Left/Late to 0

data.loc[data["STAYED"] == "Y", "STAYED"] = 1
data.loc[data["STAYED"] == "N", "STAYED"] = 0
data.loc[data["STAYED"] == "L", "STAYED"] = 0

# We should now see the data in numeric values
data


Out[11]:
PERSON TALKS GENDER STAYED
0 H1 27 0 1
1 01 1 0 1
2 02 1 0 1
3 03 0 0 1
4 04 8 0 1
5 05 12 0 1
6 06 1 0 0
7 07 5 0 1
8 08 1 0 0
9 09 1 0 1
10 10 9 0 1
11 11 5 0 1
12 12 2 0 1
13 13 6 0 1
14 14 4 0 1
15 15 3 0 1
16 16 6 0 1
17 17 0 0 1
18 18 0 0 1
19 19 0 0 1
20 20 0 0 0
21 21 0 0 1
22 22 0 0 0
23 23 0 0 0
24 24 0 1 1
25 25 2 0 0
26 26 1 0 0
27 27 1 0 0

Analysis and Visualization (V1)

Let's do some really basic passes at the data before we run some mathematical computations on it, just to get a better sense of where it stands at the moment.


In [12]:
# Run Describe to give us some basic Min/Max/Mean/Std values

data.describe()


Out[12]:
TALKS
count 28.000000
mean 3.428571
std 5.613664
min 0.000000
25% 0.000000
50% 1.000000
75% 5.000000
max 27.000000

In [13]:
# Run Value_Counts in order to see some basic grouping by attribute

vc_talks = data['TALKS'].value_counts()
vc_talks


Out[13]:
0     9
1     7
6     2
5     2
2     2
27    1
12    1
9     1
8     1
4     1
3     1
Name: TALKS, dtype: int64

In [14]:
vc_gender = data['GENDER'].value_counts()
vc_gender


Out[14]:
0    27
1     1
Name: GENDER, dtype: int64

In [15]:
vc_stayed = data['STAYED'].value_counts()
vc_stayed


Out[15]:
1    20
0     8
Name: STAYED, dtype: int64

In [16]:
# Now let's do some basic plotting with MatPlotLib

data.plot()


Out[16]:
<matplotlib.axes._subplots.AxesSubplot at 0x113010470>

In [17]:
data.plot(kind='bar')


Out[17]:
<matplotlib.axes._subplots.AxesSubplot at 0x113023358>

In [18]:
fig1, ax1 = plt.subplots()
ax1.pie(data['TALKS'], autopct='%1.f%%', shadow=True, startangle=90)
ax1.axis('equal')
plt.show()


Analysis and Visualization (V2)

As per the methodology in the first notebook, for the sake of mapping the actual conversational flow amongst the participants, I am going to run these analyses and visualizations again while removing the hosts...


In [19]:
data_hostless = data.drop(data.index[[0]])

In [20]:
data_hostless.head()


Out[20]:
PERSON TALKS GENDER STAYED
1 01 1 0 1
2 02 1 0 1
3 03 0 0 1
4 04 8 0 1
5 05 12 0 1

In [21]:
data_hostless.describe()


Out[21]:
TALKS
count 27.000000
mean 2.555556
std 3.250247
min 0.000000
25% 0.000000
50% 1.000000
75% 4.500000
max 12.000000

In [22]:
dh_vc_talks = data_hostless['TALKS'].value_counts()
dh_vc_talks


Out[22]:
0     9
1     7
6     2
5     2
2     2
12    1
9     1
8     1
4     1
3     1
Name: TALKS, dtype: int64

In [23]:
dh_vc_gender = data_hostless['GENDER'].value_counts()
dh_vc_gender


Out[23]:
0    26
1     1
Name: GENDER, dtype: int64

In [24]:
dh_vc_stayed = data_hostless['STAYED'].value_counts()
dh_vc_stayed


Out[24]:
1    19
0     8
Name: STAYED, dtype: int64

In [25]:
data_hostless.plot()


Out[25]:
<matplotlib.axes._subplots.AxesSubplot at 0x113c9c160>

In [26]:
data_hostless.plot(kind='bar')


Out[26]:
<matplotlib.axes._subplots.AxesSubplot at 0x113c9a7f0>

In [27]:
fig1, ax1 = plt.subplots()
ax1.pie(data_hostless['TALKS'], autopct='%1.f%%', shadow=True, startangle=90)
ax1.axis('equal')
plt.show()


this is getting there...

Algebraic Analysis

Now lets step into some deeper (but probaby still naive) analysis based off of my rudiemtary understanding of Data Science! :D


In [28]:
# Percentage of attendees that were silent during the talk

silent = percent_silent(data['TALKS'])
silent


Out[28]:
{'SILENT': 9, 'TOTAL': 28, 'VERBOSE': 19}

In [29]:
fig1, ax1 = plt.subplots()

sizes = [silent['SILENT'], silent['VERBOSE']]
labels = 'Silent', 'Talked'
explode = (0.05, 0)

ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.0f%%', shadow=True, startangle=90)
ax1.axis('equal')
plt.show()



In [30]:
# Percentage of attendees that left early during the talk

left = percent_left(data['STAYED'])
left


Out[30]:
{'LEFT': 8, 'STAYED': 20, 'TOTAL': 28}

In [31]:
fig1, ax1 = plt.subplots()

sizes = [left['LEFT'], left['STAYED']]
labels = 'Left', 'Stayed'
explode = (0.1, 0)

ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.0f%%', shadow=True, startangle=90)
ax1.axis('equal')
plt.show()



In [32]:
# Percentage of attendees that were Male vs. Female (see notes above around methodology)

gender = percent_gender(data['GENDER'])
gender


Out[32]:
{'FEMALE': 1, 'MALE': 27, 'TOTAL': 28}

In [33]:
fig1, ax1 = plt.subplots()

sizes = [gender['FEMALE'], gender['MALE']]
labels = 'Female', 'Male'
explode = (0.1, 0)

ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.0f%%', shadow=True, startangle=90)
ax1.axis('equal')
plt.show()



In [34]:
# Calculate Percent of Talking points by GENDER

distribution = percent_talking_gender(data[['TALKS','GENDER']])
distribution


Out[34]:
{'FEMALE': 0, 'MALE': 19, 'TOTAL': 19}

In [35]:
fig1, ax1 = plt.subplots()

sizes = [distribution['FEMALE'], distribution['MALE']]
labels = 'Female Speakers', 'Male Speakers'
explode = (0.1, 0)

ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.0f%%', shadow=True, startangle=90)
ax1.axis('equal')
plt.show()


these numbers are damning...


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: