In [9]:
# Visualize results

# import packages
import pickle
from matplotlib import pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
import random
import math
%matplotlib inline

# Read in results
with open('all_scores_hum.p', 'rb') as all_scores_f:
  all_scores_hum = pickle.load(all_scores_f)

with open('selected_scores_hum.p', 'rb') as selected_scores_f:
  selected_scores_hum = pickle.load(selected_scores_f)

with open('all_scores_mus.p', 'rb') as all_scores_f:
  all_scores_mus = pickle.load(all_scores_f)

with open('selected_scores_mus.p', 'rb') as selected_scores_f:
  selected_scores_mus = pickle.load(selected_scores_f)

In [10]:
df1 = pd.DataFrame({'all_hum': [math.log(s + 0.00000001, 10) for s in all_scores_hum]})
df2 = pd.DataFrame({'selected_hum': [math.log(s + 0.00000001, 10) for s in selected_scores_hum]})
df3 = pd.DataFrame({'all_mus': [math.log(s + 0.00000001, 10) for s in all_scores_mus]})
df4 = pd.DataFrame({'selected_mus': [math.log(s + 0.00000001, 10) for s in selected_scores_mus]})

df = pd.concat([df1,df2,df3,df4], ignore_index=True, axis=1)

In [52]:
plt.clf()
sns.set(style="dark")
sns.set(font_scale = 2)
plt.figure(figsize=(15,10))

vplot = sns.violinplot(df,  palette=['g','g','m','m'])

#title = ('')


#vplot.set_title(title, fontsize=20

vplot.set_xlabel('Series', fontsize=26)
vplot.set_ylabel('log(G-score)', fontsize=26)
vplot.set_xticklabels(['All','Selected','All','Selected'])

#handles, labels = vplot.fig.get_axes()[0].get_legend_handles_labels()
#vplot.fig.get_axes()[0].legend([handles[1]], ["Non-smoker"], loc='upper left')

#vplot.tick_params(axis='both', labelsize=12)

#sns.despine() 
           
plt.savefig('violin.pdf')


<matplotlib.figure.Figure at 0x11075f590>

In [54]:
def percent_0(l):
    denom = float(len(l))
    numer = len(filter(lambda x: x == 0, l))
    
    return numer / denom

In [56]:
print 'all_scores_hum', percent_0(all_scores_hum)
print 'selected_scores_hum', percent_0(selected_scores_hum)
print 'all_scores_mus', percent_0(all_scores_mus)
print 'selected_scores_mus', percent_0(selected_scores_mus)


all_scores_hum 0.426571706446
selected_scores_hum 0.889118742242
all_scores_mus 0.60282519738
selected_scores_mus 0.977992744861

In [ ]: