In [ ]:
# import the modules
import GPy
import csv
import numpy as np
import cPickle as pickle
import scipy.stats as stats
import sklearn.metrics as metrics
import GPy.plotting.Tango as Tango
from matplotlib import pyplot as plt
%matplotlib notebook
In [ ]:
kinectExt = 'C'
kinectDim = 7500
kinectKey = 'Cloud'
mocapDim = 8
mocapExt = 'T'
mocapKey = 'TopCoord'
dataTypes = ['train','test']
parameters = ['rmse','nrmse','corr']
In [ ]:
nShr = 4
nPos = 6
nTypes = 2
nParam = 3
dims = [kinectDim,mocapDim]
keys = [kinectKey,mocapKey]
metricRes = np.zeros((nTypes,nParam,nShr,nPos))
for dT,dataType in enumerate(dataTypes):
for sInd in range(nShr):
for pInd in range(nPos):
res = pickle.load(open('../Results/Exp7/Res%d%d.p' % (sInd+1,pInd+1),'rb'))
for p,parameter in zip(range(len(parameters)),parameters):
metricRes[dT,p,sInd,pInd] = res[dataType][parameter].mean()
pickle.dump(metricRes,open('Result/metricResults.p','wb'))
In [ ]:
def plotScales(train, test, options):
fSize = 20
fig = plt.figure()
ax = fig.add_subplot(111)
x1 = np.arange(0.85,train.shape[0]+0.85)
x2 = np.arange(1.15,train.shape[0]+1.15)
c1 = Tango.colorsHex['mediumBlue']
c2 = Tango.colorsHex['mediumRed']
p1 = ax.bar(x1, height=train, width=0.25, align='center', color=c1, edgecolor='k', linewidth=1.2)
p2 = ax.bar(x2, height=test, width=0.25, align='center', color=c2, edgecolor='k', linewidth=1.2)
ax.plot([0.5, train.shape[0]+0.5], [train.mean(), train.mean()], '--', linewidth=3, color=Tango.colorsHex['mediumBlue'])
ax.plot([0.5, train.shape[0]+0.5], [test.mean(), test.mean()], '--', linewidth=3, color=Tango.colorsHex['mediumRed'])
# setting the bar plot parameters
ax.set_ylim(options['ylimits'])
ax.set_xlim(0.5, train.shape[0]+0.5)
ax.tick_params(axis='both', labelsize=fSize)
ax.set_xticks(xrange(1, train.shape[0]+1))
ax.set_title(options['title'], fontsize=fSize)
ax.set_ylabel(options['ylabel'], fontsize=fSize)
ax.set_xlabel(options['xlabel'], fontsize=fSize)
ax.legend([p1,p2], options['legend'], fontsize=fSize-5, loc=2)
plt.tight_layout()
return ax
In [ ]:
def plotScales1(test, options, a=0, n=6):
fSize = 20
fig = plt.figure()
ax = fig.add_subplot(111)
x = np.arange(1,n+1)
c = Tango.colorsHex['mediumRed']
ax.bar(x, height=test.mean(axis=a), width=0.4, align='center', color=c, edgecolor='k', linewidth=1.2)
# setting the bar plot parameters
ax.set_xlim(0.0, n+1.0)
ax.set_ylim(options['ylimits'])
ax.tick_params(axis='both', labelsize=fSize)
ax.set_xticks(xrange(1, n+1))
ax.set_title(options['title'], fontsize=fSize)
ax.set_ylabel(options['ylabel'], fontsize=fSize)
ax.set_xlabel(options['xlabel'], fontsize=fSize)
#ax.legend(options['legend'], fontsize=20, loc=2)
plt.tight_layout()
return ax
In [ ]:
options = {'title':'','ylabel':'RMSE','xlabel':'T-shirt Index',
'legend':['Seen T-shirt','Unseen T-shirt'], 'ylimits':[0.3,0.76]}
plotScales(metricRes[0,0,:,:].mean(axis=1), metricRes[1,0,:,:].mean(axis=1), options)
plt.savefig('Result/shirtRMSE.pdf', format='pdf')
In [ ]:
options = {'title':'','ylabel':'NRMSE','xlabel':'T-shirt Index',
'legend':['Seen T-shirt','Unseen T-shirt'], 'ylimits':[0.0,0.28]}
plotScales(metricRes[0,1,:,:].mean(axis=1), metricRes[1,1,:,:].mean(axis=1), options)
plt.savefig('Result/shirtNRMSE.pdf', format='pdf')
In [ ]:
options = {'title':'','ylabel':'NRMSE','xlabel':'T-shirt Index',
'legend':['Seen T-shirt','Unseen T-shirt'], 'ylimits':[0.8,1.03]}
plotScales(metricRes[0,2,:,:].mean(axis=1), metricRes[1,2,:,:].mean(axis=1), options)
plt.savefig('Result/shirtCorr.pdf', format='pdf')