In [1]:
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
In [2]:
dropoutmc_sgldlr = pd.read_csv('DropoutMC_SGLD_LR.csv')
dropoutmc_sgldlr['Method'] = 'Dropout-MC'
dropoutmc_adam = pd.read_csv('DropoutMC_Adam.csv')
dropoutmc_adam['Method'] = 'Dropout-MC'
fullensemble_sgldlr = pd.read_csv('Full_Ensemble_SGLD_LR.csv')
fullensemble_sgldlr['Method'] = 'Full Ensemble'
fullensemble_adam = pd.read_csv('Full_Ensemble_Adam.csv')
fullensemble_adam['Method'] = 'Full Ensemble'
vi_sgldlr = pd.read_csv('VI_KLpq_SGLD_LR.csv')
vi_sgldlr['Method'] = 'VI'
vi_adam = pd.read_csv('VI_KLpq_Adam.csv')
vi_adam['Method'] = 'VI'
onlinegauss_sgldlr = pd.read_csv('SampledGauss_SGLD_LR.csv')
onlinegauss_sgldlr['Method'] = 'Ours'
onlinegauss_adam = pd.read_csv('SampledGauss_noisyAdam.csv')
onlinegauss_adam['Method'] = 'Ours'
sgldlr_df = pd.concat([dropoutmc_sgldlr, fullensemble_sgldlr, onlinegauss_sgldlr])#, vi_sgldlr])
sgld_groups = sgldlr_df.groupby(['Method', 'samples'])
print('SGLD')
print(pd.concat((sgld_groups['acc'].mean(), sgld_groups['acc'].std()), axis=1))
sgldlr_df = sgldlr_df.loc[sgldlr_df['samples'] > 1.]
sgldlr_df.loc[:, 'Recall'] = sgldlr_df.loc[:, 'TP']/(sgldlr_df.loc[:, 'TP']+sgldlr_df.loc[:, 'FP'])
sgldlr_df.loc[:, 'Precision'] = sgldlr_df.loc[:, 'TP']/(sgldlr_df.loc[:, 'TP']+sgldlr_df.loc[:, 'FN'])
sgldlr_df = sgldlr_df.fillna(value=0.)
adam_df = pd.concat([dropoutmc_adam, fullensemble_adam, onlinegauss_adam])#, vi_adam])
adam_groups = adam_df.groupby(['Method', 'samples'])
print('Adam')
print(pd.concat((adam_groups['acc'].mean(), adam_groups['acc'].std()), axis=1))
adam_df = adam_df.loc[adam_df['samples'] > 1.]
adam_df.loc[:, 'Recall'] = adam_df.loc[:, 'TP']/(adam_df.loc[:, 'TP']+adam_df.loc[:, 'FP'])
adam_df.loc[:, 'Precision'] = adam_df.loc[:, 'TP']/(adam_df.loc[:, 'TP']+adam_df.loc[:, 'FN'])
adam_df = adam_df.fillna(value=0.)
In [3]:
cmap_1 = [sns.xkcd_rgb["red"], sns.xkcd_rgb["orange"], sns.xkcd_rgb["blue"]]
sns.tsplot(data=sgldlr_df, time='samples', unit='run', value='Recall',
legend=True, condition="Method", color=cmap_1)
plt.xlabel('Ensemble size')
plt.ylabel('Recall')
plt.axis([2, 15, 0.5, 1.0])
plt.show()
sns.tsplot(data=sgldlr_df, time='samples', unit='run', value='Precision',
legend=True, condition="Method", color=cmap_1)
plt.axis([2, 15, 0.0, 1.0])
plt.xlabel('Ensemble size')
plt.ylabel('Precision')
#plt.title('Outlier detection precision')
plt.show()
sns.tsplot(data=sgldlr_df, time='samples', unit='run', value='acc',
legend=True, condition="Method", color=cmap_1)
plt.axis([2, 15, 0.0, 1.0])
plt.xlabel('Ensemble size')
plt.ylabel('Accuracy')
#plt.title('MNIST Classiciation')
plt.show()
plt.plot(sgldlr_df[sgldlr_df['Method'] == 'Dropout-MC']['Precision'],
sgldlr_df[sgldlr_df['Method'] == 'Dropout-MC']['Recall'],
color=sns.xkcd_rgb["red"], marker='x', linestyle='none'
)
plt.plot(sgldlr_df[sgldlr_df['Method'] == 'Full Ensemble']['Precision'],
sgldlr_df[sgldlr_df['Method'] == 'Full Ensemble']['Recall'],
color=sns.xkcd_rgb["orange"], marker='x', linestyle='none'
)
plt.plot(sgldlr_df[sgldlr_df['Method'] == 'Ours']['Precision'],
sgldlr_df[sgldlr_df['Method'] == 'Ours']['Recall'],
color=sns.xkcd_rgb["blue"], marker='x', linestyle='none'
)
#plt.axis([2, 15, 0.0, 1.0])
plt.xlabel('Ensemble size')
plt.ylabel('Accuracy')
#plt.title('MNIST Classiciation')
plt.show()
In [4]:
cmap_1 = [sns.xkcd_rgb["red"], sns.xkcd_rgb["orange"], sns.xkcd_rgb["blue"]]
sns.tsplot(data=adam_df, time='samples', unit='run', value='Recall',
legend=True, condition="Method", color=cmap_1)
plt.xlabel('Ensemble size')
plt.ylabel('Recall')
plt.axis([2, 15, 0.5, 1.0])
#plt.title('Outlier detection recall')
plt.show()
sns.tsplot(data=adam_df, time='samples', unit='run', value='Precision',
legend=True, condition="Method", color=cmap_1)
plt.axis([2, 15, 0.0, 1.0])
plt.xlabel('Ensemble size')
plt.ylabel('Precision')
#plt.title('Outlier detection precision')
plt.show()
sns.tsplot(data=adam_df, time='samples', unit='run', value='acc',
legend=True, condition="Method", color=cmap_1)
plt.axis([2, 15, 0.0, 1.0])
plt.xlabel('Ensemble size')
plt.ylabel('Accuracy')
#plt.title('MNIST Classiciation')
plt.show()
In [5]:
sgldlr_df['Method'] = sgldlr_df['Method'] + ' SGLD LR'
adam_df['Method'] = adam_df['Method'] + ' Adam'
all_df = pd.concat([sgldlr_df, adam_df])
cmap_1 = [sns.xkcd_rgb["red"], sns.xkcd_rgb["green"], sns.xkcd_rgb["blue"]]
cmap_2 = [sns.xkcd_rgb["dark red"], sns.xkcd_rgb["dark green"], sns.xkcd_rgb["dark blue"]]
sns.tsplot(data=sgldlr_df, time='samples', unit='run', value='Recall',
legend=True, condition="Method", color=cmap_1)
sns.tsplot(data=adam_df, time='samples', unit='run', value='Recall',
legend=True, condition="Method", color=cmap_2)
plt.xlabel('Ensemble size')
plt.ylabel('Recall')
plt.title('Outlier detection recall')
plt.show()
sns.tsplot(data=sgldlr_df, time='samples', unit='run', value='Precision',
legend=True, condition="Method", color=cmap_1)
sns.tsplot(data=adam_df, time='samples', unit='run', value='Precision',
legend=True, condition="Method", color=cmap_2)
plt.axis([1, 15, 0.0, 1.0])
plt.xlabel('Ensemble size')
plt.ylabel('Precision')
plt.title('Outlier detection precision')
plt.show()
sns.tsplot(data=sgldlr_df, time='samples', unit='run', value='acc',
legend=True, condition="Method", color=cmap_1)
sns.tsplot(data=adam_df, time='samples', unit='run', value='acc',
legend=True, condition="Method", color=cmap_2)
plt.axis([1, 15, 0.0, 1.0])
plt.xlabel('Ensemble size')
plt.ylabel('Accuracy')
plt.title('MNIST Classiciation')
plt.show()
In [ ]: