
# Principal Component Analysis Code : 

from numpy import mean,cov,double,cumsum,dot,linalg,array,rank,size,flipud
from pylab import *
import numpy as np
import matplotlib.pyplot as pp
#from enthought.mayavi import mlab

import scipy.ndimage as ni

import roslib; roslib.load_manifest('sandbox_tapo_darpa_m3')
import rospy
#import hrl_lib.mayavi2_util as mu
import hrl_lib.viz as hv
import hrl_lib.util as ut
import hrl_lib.matplotlib_util as mpu
import pickle
import matplotlib

from mvpa.clfs.knn import kNN
from mvpa.datasets import Dataset
from mvpa.clfs.transerror import TransferError
from mvpa.misc.data_generators import normalFeatureDataset
from mvpa.algorithms.cvtranserror import CrossValidatedTransferError
from mvpa.datasets.splitters import NFoldSplitter

if __name__ == '__main__':

    matplotlib.rcParams['font.size'] = 12

# Categories

# Time-Span
    cat_acc_span = np.array([62.14, 62.14, 76.43, 76.43, 79.29])
    cat_time_span = np.array([0.4, 0.8, 1.2, 1.6, 2.0])

# Time-Samples
    cat_acc_samples = np.array([72.14, 77.86, 75.71, 79.29, 72.14, 71.43])
    cat_time_samples = np.array([5, 10, 20, 40, 50, 100])

# Objects

# Time-Span
    ob_acc_span = np.array([41.43, 64.29, 71.43, 70.71, 70.71])
    ob_time_span = np.array([0.4, 0.8, 1.2, 1.6, 2.0])

# Time-Samples
    ob_acc_samples = np.array([65.71, 70.71, 68.57, 70.71, 70.71, 71.43])
    ob_time_samples = np.array([5, 10, 20, 40, 50, 100])

# Plots
# Time-Span
    figure(1)
    plot(cat_time_span,cat_acc_span,'-s', linewidth=3)
    grid('True')
    hold('True')
    plot(ob_time_span,ob_acc_span,'-s', linewidth=3)
    title('Effect of Time-Window', fontsize='14')
    legend(('Classification\n(Rigid-Fixed,Rigid-Movable)\n(Soft-Fixed,Soft-Movable)', 'Object Recognition'),loc='4')
    ylabel('Cross-Validation Accuracy', fontsize='14')
    xlabel('Time-Window', fontsize='14')
    
# Time-Samples
    figure(2)
    plot(cat_time_samples,cat_acc_samples,'-s')
    grid('True')
    hold('True')
    plot(ob_time_samples,ob_acc_samples,'-s')
    title('Effect of Time-Samples')
    legend(('Classification(Rigid-Fixed,Rigid-Movable,Soft-Fixed,Soft-Movable)', 'Object Recognition'),loc='4')
    ylabel('Cross-Validation Accuracy')
    xlabel('No. of Time-Samples')
    
    show()



