#! /usr/bin/python import numpy as np import matplotlib.pyplot as plt import matplotlib.mlab as mlab import sys import os import scipy import matplotlib as mpl mpl.rcParams['font.size'] = 8 mpl.rcParams['lines.linewidth'] = 0.5 mpl.rcParams['figure.figsize'] = 6,5 mpl.rcParams['legend.fontsize'] = 8 mpl.rcParams['axes.linewidth'] = 0.8 out_dir = sys.argv[1] #limbs distribution plt.figure() data = np.loadtxt("../limbs-avg-zdiff/data.csv",delimiter=",") data = data[#(data[:,1] == 25) ((data != -1).all(1)) & (data[:,4]>2) & (data[:,4]<3)] data = data[:,7:]*100 mean = data.mean(0) var = data.std(0) for i in range(len(mean)): ax = plt.subplot(2,5,i+1) n,b,p = plt.hist(data[:,i],bins=100,normed=1,linewidth=0) plt.plot(b,mlab.normpdf(b,mean[i],var[i])) plt.savefig(os.path.join(out_dir,"limbs.pdf"),bbox_inches="tight",pad_inches=0.05) #frames distribution fig = plt.figure(figsize=(6,4)) x = np.loadtxt("frames.txt",usecols=(0,)) y = range(1,len(x)+1) width=0.8 plt.bar(y,x/x.sum()*100,width=width) plt.xlim(0.8,26) plt.xticks([i+width/2. for i in range(1,len(x),5)], range(1,len(x),5)) plt.xlabel("Individual") plt.ylabel("Frame ratio [%]") plt.ylim(0,17) ax = plt.gca() plt.savefig(os.path.join(out_dir,"frames.pdf"),bbox_inches="tight",pad_inches=0.05) l = ["3","5","10","all"] #10-fold, naive plt.figure() for i in l: x,y = np.loadtxt(i+"_nb_off.mat",unpack=True) plt.plot(100*x,100*y,label="$n_p=$ "+i) plt.xlabel("Recall [%]") plt.ylabel("Precision [%]") plt.legend(loc="best") plt.axis([0,100,50,100]) plt.savefig(os.path.join(out_dir,"offline-nb.pdf"),bbox_inches="tight",pad_inches=0.05) #10-fold, SHT plt.figure() for i in l: x,y = np.loadtxt(i+"_sht_off.mat",unpack=True) plt.plot(100*x,100*y,label="$n_p=$ "+i) plt.xlabel("Recall [%]") plt.ylabel("Precision [%]") plt.legend(loc="lower left") plt.axis([0,100,50,100]) plt.savefig(os.path.join(out_dir,"offline-sht.pdf"),bbox_inches="tight",pad_inches=0.05) #online,NB plt.figure() for i in l: x,y = np.loadtxt(i+"_nb_on.mat",unpack=True) plt.plot(100*x,100*y,label="$n_p=$ "+i) plt.xlabel("Recall [%]") plt.ylabel("Precision [%]") plt.legend(loc="best") plt.axis([0,100,50,100]) plt.savefig(os.path.join(out_dir,"online-nb.pdf"),bbox_inches="tight",pad_inches=0.05) #online,SHT plt.figure() for i in l: x,y = np.loadtxt(i+"_sht_on.mat",unpack=True) plt.plot(100*x,100*y,label="$n_p=$ "+i) plt.xlabel("Recall [%]") plt.ylabel("Precision [%]") plt.legend(loc="best") plt.axis([0,100,50,100]) plt.savefig(os.path.join(out_dir,"online-sht.pdf"),bbox_inches="tight",pad_inches=0.05) #face plt.figure() x,y = np.loadtxt("all_nb_off.mat",unpack=True) a,b = np.loadtxt("face.csv",delimiter=",", unpack=True) plt.plot(100*x,100*y,label="Skeleton") plt.plot(100*a,100*b,label="Face") plt.xlabel("Recall [%]") plt.ylabel("Precision [%]") plt.legend(loc="best") plt.axis([0,100,50,100]) plt.savefig(os.path.join(out_dir,"face.pdf"),bbox_inches="tight",pad_inches=0.05) #back plt.figure() x,y = np.loadtxt("back_all_sht_on.mat",unpack=True) a,b = np.loadtxt("all_sht_on.mat",unpack=True) c,d = np.loadtxt("front_back_all_sht.mat",unpack=True) plt.plot(100*a,100*b,label="Train/test toward") plt.plot(100*x,100*y,label="Train/test away") plt.plot(100*c,100*d,label="Train toward test away") plt.xlabel("Recall [%]") plt.ylabel("Precision [%]") plt.legend(loc="best") plt.axis([0,100,50,100]) plt.savefig(os.path.join(out_dir,"back.pdf"),bbox_inches="tight",pad_inches=0.05) #variance-reduction plt.figure() x,y = np.loadtxt("half-var-all_sht_on.mat",unpack=True) a,b = np.loadtxt("all_sht_on.mat",unpack=True) plt.plot(100*x,100*y,label="Reduced noise") plt.plot(100*a,100*b,label="Original noise") plt.xlabel("Recall [%]") plt.ylabel("Precision [%]") plt.legend(loc="best") plt.axis([0,100,50,100]) plt.savefig(os.path.join(out_dir,"var.pdf"),bbox_inches="tight",pad_inches=0.05)