Experiment 6: TRo Journal


In this experiment, the generalization of cloth models to unseen postures of the mannequin is verified. The evaluation is performed using RMSE, NRMSE, Pearson correlation as the parameters. In this notebook, the generalizability to unseen postures is evaluated through plots.


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

Data Loading



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/Exp6/MRDRes%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'))

Plotting



In [ ]:
def plotScales(train, test, options, a=0, n=6, legendFlag=True, legendLoc=2):
    fSize = 20
    fig = plt.figure()
    ax = fig.add_subplot(111)
    
    x1 = np.arange(0.75,n+0.75)
    x2 = np.arange(1.25,n+1.25)
    c1 = Tango.colorsHex['mediumBlue']
    c2 = Tango.colorsHex['mediumRed']
    ax.bar(x1, height=train.mean(axis=a), width=0.4, align='center', color=c1, edgecolor='k', linewidth=1.2)
    ax.bar(x2, height=test.mean(axis=a), width=0.4, align='center', color=c2, 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)
    if legendFlag:
        ax.legend(options['legend'], fontsize=fSize-5, loc=legendLoc)
    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=fSize, loc=2)
    plt.tight_layout()
    return ax

In [ ]:
options = {'title':'','ylabel':'RMSE','xlabel':'Posture Index', 
           'legend':['Train','Test'], 'ylimits':[0.0,0.8]}
plotScales(metricRes[0,0,:,:], metricRes[1,0,:,:], options)
plt.savefig('Result/posRMSE.pdf', format='pdf')

In [ ]:
options = {'title':'','ylabel':'NRMSE','xlabel':'Posture Index', 
           'legend':['Train','Test'], 'ylimits':[0.0,0.21]}
plotScales(metricRes[0,1,:,:], metricRes[1,1,:,:], options)
plt.savefig('Result/posNRMSE.pdf', format='pdf')

In [ ]:
options = {'title':'','ylabel':'Pearson Corr.','xlabel':'Posture Index', 
           'legend':['Train','Test'], 'ylimits':[0.85,1.0]}
plotScales(metricRes[0,2,:,:], metricRes[1,2,:,:], options, legendFlag=False)
plt.savefig('Result/posCorr.pdf', format='pdf')