In [20]:
import numpy as np
import matplotlib.pyplot as plt;
import matplotlib as mpl
import prettyplotlib as ppl

%matplotlib inline

In [38]:
# batch_50-25-10.d 
A = \
[[ 59.7756356 ,  64.58333333,  66.66666667],
 [ 61.27136946,  63.88888889,  66.66666667],
 [ 59.8290503 ,  66.31944444,  75.        ],
 [ 63.94231319,  65.27777778,  70.83333333],
 [ 57.23824799,  60.06944444,  66.66666667],
 [ 58.18540454,  62.17948718,  62.5       ],
 [ 51.60256624,  50.32051282,  62.5       ],
 [ 62.35207319,  69.23076923,  87.5       ],
 [ 82.84023702,  86.21794872,  91.66666667],
 [ 55.54733872,  55.76923077,  62.5       ],
 [ 64.32446241,  76.92307692,  83.33333333],
 [ 64.10256326,  73.3974359 ,  83.33333333],
 [ 53.52564752,  57.69230769,  62.5       ]]
# [ 61.1182238   65.52843524  72.43589744]

In [40]:
# sda_100Hz_100-50-25-10.cfg
B = \
[[ 57.31837451,  52.43055556,  50.        ],
 [ 52.67093778,  58.68055556,  66.66666667],
 [ 60.01601815,  67.01388889,  75.        ],
 [ 63.51494789,  67.70833333,  62.5       ],
 [ 49.94657636,  50.        ,  50.        ],
 [ 55.57199419,  60.25641026,  66.66666667],
 [ 49.53156114,  52.24358974,  66.66666667],
 [ 53.42701674,  57.69230769,  75.        ],
 [ 81.63215071,  86.53846154,  91.66666667],
 [ 56.28697872,  62.82051282,  66.66666667],
 [ 63.85602057,  66.34615385,  58.33333333],
 [ 61.19329035,  70.19230769,  83.33333333],
 [ 50.27120113,  54.48717949,  54.16666667]]
#[ 58.0951591   62.03155819  66.66666667]

In [39]:
# sda_100Hz_100-50-25.cfg
C = \
[[ 59.37499702,  69.79166667,  79.16666667],
 [ 59.88247693,  62.15277778,  66.66666667],
 [ 61.35148406,  68.05555556,  75.        ],
 [ 64.74359035,  65.625     ,  70.83333333],
 [ 57.26495385,  62.5       ,  70.83333333],
 [ 58.72781277,  66.34615385,  66.66666667],
 [ 55.1282078 ,  52.24358974,  58.33333333],
 [ 61.16863489,  64.42307692,  70.83333333],
 [ 84.31952745,  88.46153846,  91.66666667],
 [ 57.42110312,  58.33333333,  58.33333333],
 [ 66.86390936,  78.52564103,  83.33333333],
 [ 63.78204226,  65.70512821,  75.        ],
 [ 51.94773674,  54.16666667,  58.33333333]]
#[ 61.6904982   65.87154832  71.15384615]

In [41]:
# sda_400Hz_100-50-25-10.cfg
D = \
[[ 50.68301558,  50.        ,  50.        ],
 [ 55.23110926,  71.18055556,  75.        ],
 [ 51.12699568,  49.65277778,  50.        ],
 [ 50.74000657,  56.59722222,  58.33333333],
 [ 49.15188551,  45.83333333,  50.        ],
 [ 52.24359035,  65.06410256,  66.66666667],
 [ 51.9020468 ,  55.76923077,  54.16666667],
 [ 51.32409334,  59.29487179,  58.33333333],
 [ 55.81128597,  88.78205128,  91.66666667],
 [ 50.96679032,  55.12820513,  54.16666667],
 [ 51.50797665,  58.97435897,  62.5       ],
 [ 50.27846694,  56.73076923,  70.83333333],
 [ 51.00881159,  52.88461538,  66.66666667]]
#[ 51.69046728  58.91477646  62.17948718]

In [43]:
# sda_400Hz_100-50-25.cfg
E = \
[[ 61.7656976 ,  60.06944444,  70.83333333],
 [ 77.26547718,  80.20833333,  83.33333333],
 [ 56.8305999 ,  68.05555556,  62.5       ],
 [ 58.9708358 ,  60.76388889,  75.        ],
 [ 50.15366077,  48.61111111,  66.66666667],
 [ 66.46700501,  69.55128205,  70.83333333],
 [ 58.62234533,  61.85897436,  66.66666667],
 [ 52.79529095,  53.20512821,  87.5       ],
 [ 80.0073579 ,  88.46153846,  91.66666667],
 [ 52.76376605,  61.53846154,  75.        ],
 [ 57.99705386,  71.15384615,  83.33333333],
 [ 64.76986408,  74.35897436,  83.33333333],
 [ 54.90754843,  54.48717949,  75.        ]]
#[ 61.02434637  65.56336292  76.28205128]

In [44]:
# sda_400Hz_80-50-25-10.cfg
F = \
[[ 49.70237613,  53.47222222,  54.16666667],
 [ 55.93884587,  76.04166667,  83.33333333],
 [ 50.3697753 ,  55.55555556,  58.33333333],
 [ 51.26712024,  56.25      ,  58.33333333],
 [ 48.69226813,  47.91666667,  41.66666667],
 [ 50.68266094,  59.61538462,  62.5       ],
 [ 51.23209357,  57.05128205,  70.83333333],
 [ 50.41625202,  52.56410256,  50.        ],
 [ 61.10556722,  88.46153846,  95.83333333],
 [ 50.73261559,  54.16666667,  54.16666667],
 [ 54.69945371,  67.30769231,  70.83333333],
 [ 50.56193769,  58.01282051,  62.5       ],
 [ 50.31217337,  52.88461538,  50.        ]]
#[ 51.97793383  59.94617028  62.5       ]

In [208]:
# cnn/exp09.1-1s
G = \
[[ 59.84744728,  70.48611111,  75.        ],
 [ 66.10883772,  65.625     ,  66.66666667],
 [ 61.35586202,  66.31944444,  66.66666667],
 [ 65.7445401 ,  68.75      ,  70.83333333],
 [ 58.15118551,  58.68055556,  66.66666667],
 [ 63.1883204 ,  66.02564103,  75.        ],
 [ 56.17909729,  57.05128205,  62.5       ],
 [ 60.82387269,  63.78205128,  75.        ],
 [ 86.31253093,  89.1025641 ,  91.66666667],
 [ 54.33481038,  49.35897436,  45.83333333],
 [ 60.47183275,  59.29487179,  62.5       ],
 [ 63.00967336,  66.02564103,  70.83333333],
 [ 51.06139779,  50.32051282,  50.        ]]
#[ 62.04533909  63.90943458  67.62820513]

In [209]:
# cnn/exp07.1
H = \
[[ 63.02507222,  67.36111111,  79.16666667],
 [ 66.81063473,  66.66666667,  70.83333333],
 [ 64.67649341,  67.70833333,  66.66666667],
 [ 67.47120917,  70.83333333,  70.83333333],
 [ 61.47527695,  59.72222222,  66.66666667],
 [ 64.8999393 ,  65.06410256,  66.66666667],
 [ 52.5172025 ,  54.16666667,  58.33333333],
 [ 64.79832828,  66.66666667,  75.        ],
 [ 89.49343115,  89.74358974,  91.66666667],
 [ 58.12226534,  56.41025641,  58.33333333],
 [ 65.32206833,  62.82051282,  62.5       ],
 [ 63.71168792,  62.82051282,  62.5       ],
 [ 49.77329969,  50.32051282,  54.16666667]]
#[ 64.00745454  64.63880671  67.94871795]

In [210]:
# fftcnn/exp09.a-fftcnn22
I = \
[[ 66.29661322,  64.93055556,  62.5       ],
 [ 84.95522887,  86.45833333,  91.66666667],
 [ 62.33099103,  66.31944444,  75.        ],
 [ 71.14402354,  75.        ,  75.        ],
 [ 50.54375231,  50.        ,  58.33333333],
 [ 71.12011313,  74.03846154,  75.        ],
 [ 63.57963085,  64.1025641 ,  70.83333333],
 [ 64.2375201 ,  65.70512821,  75.        ],
 [ 92.28660613,  92.62820513,  95.83333333],
 [ 70.26822269,  75.        ,  75.        ],
 [ 55.54575324,  54.48717949,  58.33333333],
 [ 82.25793093,  82.69230769,  83.33333333],
 [ 68.48009825,  69.23076923,  75.        ]]

In [211]:
# fftcnn/exp08.b
J = \
[[ 71.91585004,  71.18055556,  83.33333333],
 [ 86.34259254,  87.5       ,  91.66666667],
 [ 66.01988375,  66.66666667,  75.        ],
 [ 71.05800211,  70.83333333,  75.        ],
 [ 52.52586603,  52.08333333,  58.33333333],
 [ 74.56635237,  76.28205128,  79.16666667],
 [ 63.04675043,  63.14102564,  66.66666667],
 [ 64.9195224 ,  65.38461538,  79.16666667],
 [ 92.53393635,  92.62820513,  95.83333333],
 [ 73.9567399 ,  75.64102564,  75.        ],
 [ 60.42608917,  59.93589744,  62.5       ],
 [ 88.40497732,  89.1025641 ,  91.66666667],
 [ 69.75865066,  69.87179487,  75.        ]]
# [ 71.95963178  72.32700526  77.56410256]

In [214]:
meta = [A,B,C,D,E,F,G,H,I,J]
print np.mean(meta, axis=0) # mean over configurations
#print np.mean(meta, axis=1) # mean over subjects
#print np.mean(meta, axis=2) # mean over frames/channels/trials
print np.max(meta, axis=0).max(axis=1)


[[ 59.97050792  62.43055556  67.08333333]
 [ 66.64775103  71.84027778  76.25      ]
 [ 59.39071536  64.16666667  67.91666667]
 [ 62.8596589   65.76388889  68.75      ]
 [ 53.51436734  53.54166667  59.58333333]
 [ 61.5653193   66.44230769  69.16666667]
 [ 55.33415019  56.79487179  63.75      ]
 [ 58.62626046  61.79487179  73.33333333]
 [ 80.63426308  89.1025641   92.91666667]
 [ 58.04006308  60.41666667  62.5       ]
 [ 60.101462    65.57692308  68.75      ]
 [ 65.20724341  69.90384615  76.66666667]
 [ 55.10465652  56.63461538  62.08333333]]
[ 83.33333333  91.66666667  75.          75.          70.83333333
  79.16666667  70.83333333  87.5         95.83333333  75.64102564
  83.33333333  91.66666667  75.        ]

In [215]:
font = {
#         'family' : 'normal',
        'weight' : 'normal',
        'size'   : 14}

mpl.rc('font', **font)

def plot_data(plotdata, acc_level, ylim=[45,95]):
    exp_labels = ['A','B','C','D','E','F','G','H','I','J','K','L'];
    print exp_labels
    # Create a figure instance
    fig = plt.figure(1, figsize=(7, 3), dpi=600)
    
    best = np.argmax(plotdata, axis=0)
    print best
    x_labels = [];
    for i in xrange(13):
#         x_labels[i] = str(i+1)+'('+str(exp_labels[i])+')'; ({1})'.format(l,str(exp_labels[i]));
        best = np.max(np.where(plotdata[:,i] == plotdata[:,i].max()));
        if i in [0,1,2,6,7,8]:
            x_labels.append('*{} ({})'.format(i+1,exp_labels[best]));
        else:
            x_labels.append('{} ({})'.format(i+1,exp_labels[best]));
    print x_labels 
    
    # Create an axes instance
    ax = fig.add_subplot(111)
    
#     plt.setp('xtickNames', rotation=45, fontsize=13)
    ax.set_xticklabels(x_labels,rotation=45, fontsize=13)
    ax.set_yticks([50,60,70,80,90]);
    
#     ax.text(0, 2, '* \'fast\' group')
    
    plt.ylim(*ylim)
    plt.xlabel('subjects (with best configuration, * = \'fast\' group)')
    plt.ylabel(acc_level+' accuracy (%)')
    
    # Create the boxplot
    bp = ax.boxplot(plotdata)
    
    # Save the figure
    fig.savefig('subject-meta-'+acc_level+'.pdf', bbox_inches='tight')

In [217]:
full_data = np.asarray(meta)
frames = full_data[:,:,0] # only frame values
# print frames
plot_data(frames, 'frame')

# print frames.argmax(axis=0)

# for i in xrange(0,13):
#     print frames[:,i].argmax()
#     print np.where(frames[:,i] == frames[:,i].max()) # => no multiple max


['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L']
[9 9 9 8 7 9 8 9 9 9 2 9 9]
['*1 (J)', '*2 (J)', '*3 (J)', '4 (I)', '5 (H)', '6 (J)', '*7 (I)', '*8 (J)', '*9 (J)', '10 (J)', '11 (C)', '12 (J)', '13 (J)']

In [218]:
plot_data(full_data[:,:,1], 'channel', ylim=[40,100])


['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L']
[9 9 2 8 2 9 8 0 8 9 2 9 9]
['*1 (J)', '*2 (J)', '*3 (E)', '4 (I)', '5 (C)', '6 (J)', '*7 (I)', '*8 (A)', '*9 (J)', '10 (J)', '11 (C)', '12 (J)', '13 (J)']

In [219]:
plot_data(full_data[:,:,2], 'trial', ylim=[40,100])


['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L']
[9 8 0 4 2 9 5 0 5 4 0 9 4]
['*1 (J)', '*2 (J)', '*3 (J)', '4 (J)', '5 (C)', '6 (J)', '*7 (I)', '*8 (E)', '*9 (J)', '10 (J)', '11 (E)', '12 (J)', '13 (J)']

In [ ]: