In [1]:
%matplotlib inline
%pylab inline


Populating the interactive namespace from numpy and matplotlib

Load Results


In [2]:
from menpofast.feature import no_op, fast_dsift
from alabortijcv2015.utils import pickle_load

path = '/data/'
db = 'afw'
aam_type = 'GlobalAAM_PWA'
features_type = fast_dsift.__name__
#noise_std = [0, 0.02, 0.04, 0.06, 0.08]
noise_std = [0.04]

sicn, sfcn, ssc, sbc = [], [], [], []
aicn, afcn, asc, abc = [], [], [], []
bicn, bfcn, bsc, bbc = [], [], [], []

for n in noise_std:
    #sicn.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type + '_SICN_' + db + '_' + str(n)))
    #sfcn.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_SFCN_' + db + '_' + str(n)))
    ssc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_SSC_' + db + '_' + str(n)))
    sbc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_SBC_' + db + '_' + str(n)))
    
    #aicn.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_AICN_' + db + '_' + str(n)))
    #afcn.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_AFCN_' + db + '_' + str(n)))
    asc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_ASC_' + db + '_' + str(n)))
    abc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_ABC_' + db + '_' + str(n)))
    
    #bicn.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_BICN_' + db + '_' + str(n)))
    #bfcn.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_BFCN_' + db + '_' + str(n)))
    bsc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_BSC_' + db + '_' + str(n)))
    bbc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp3_' + aam_type + '_' + features_type +  '_BBC_' + db + '_' + str(n)))
                            
    
results = [sicn, sfcn, ssc, sbc,
           aicn, afcn, asc, abc,
           bicn, bfcn, bsc, bbc]

In [3]:
results = [ssc, sbc,
           asc, abc,
           bsc, bbc]
legend_entries = ['SSC', 'SBC',
                  'ASC', 'ABC',
                  'BSC', 'BBC']

Graph 1


In [4]:
all_errors = []

for fitter_results in results:
    mean_errors = []
    for frs in fitter_results:
        errors = [fr.final_error() for fr in frs]
        mean_error = np.mean(errors)
        mean_errors.append(mean_error)
    all_errors.append(mean_errors)
    
all_errors = np.asarray(all_errors)
x_values = noise_std

In [5]:
plot(x_values, all_errors.T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Initialization')
ylabel('Mean Normalized Point-to-Point Error')


Out[5]:
<matplotlib.text.Text at 0x7ff770779f50>

Graph 2


In [6]:
all_errors = []

for fitter_results in results:
    mean_errors = []
    for frs in fitter_results:
        errors = [fr.errors() for fr in frs]
        mean_errors.append(np.mean(errors, axis=0))
    all_errors.append(mean_errors)
    
all_errors = np.asarray(all_errors)
x_values = xrange(0, fr.n_iters + 2)

In [7]:
n = 0

plot(x_values, all_errors[:, n].T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Iteration')
ylabel('Mean Normalized Point-to-Point Error')


Out[7]:
<matplotlib.text.Text at 0x7ff7704d2510>

Graph 3


In [8]:
all_costs = []

for fitter_results in results:
    mean_costs = []
    for frs in fitter_results:
        costs = [fr.costs() for fr in frs]
        mean_costs.append(np.mean(costs, axis=0))
    all_costs.append(mean_costs)
    
all_costs = np.asarray(all_costs)
x_values = xrange(0, fr.n_iters)

In [9]:
n = 0

plot(x_values, all_costs[:, n].T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Iteration')
ylabel('Mean Normalized Cost')


Out[9]:
<matplotlib.text.Text at 0x7ff770752e90>

Graph 4


In [10]:
sic = []
aic = []

for n in noise_std:
    sic.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_SIC_' + db + '_' + str(n)))
    aic.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_AIC_' + db + '_' + str(n)))

In [16]:
results = [sic, 
           aic,
           ssc, sbc,
           asc, abc,
           bsc]

legend_entries = ['SIC', 
                  'AIC',
                  'SSC', 'SBC',
                  'ASC', 'ABC',
                  'BSC']

In [17]:
all_errors = []

for fitter_results in results:
    mean_errors = []
    for frs in fitter_results:
        errors = [fr.final_error() for fr in frs]
        mean_error = np.mean(errors)
        mean_errors.append(mean_error)
    all_errors.append(mean_errors)
    
all_errors = np.asarray(all_errors)
x_values = noise_std

In [18]:
plot(x_values, all_errors.T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Initialization')
ylabel('Mean Normalized Point-to-Point Error')


Out[18]:
<matplotlib.text.Text at 0x7ff76cf53dd0>

Graph 5


In [19]:
all_errors = []

for fitter_results in results:
    mean_errors = []
    for frs in fitter_results:
        errors = [fr.errors() for fr in frs]
        mean_errors.append(np.mean(errors, axis=0))
    all_errors.append(mean_errors)
    
all_errors = np.asarray(all_errors)
x_values = xrange(0, fr.n_iters + 2)

In [20]:
n = 0

plot(x_values, all_errors[:, n].T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Iteration')
ylabel('Mean Normalized Point-to-Point Error')


Out[20]:
<matplotlib.text.Text at 0x7ff7705e0b90>

Graph 6


In [21]:
all_costs = []

for fitter_results in results:
    mean_costs = []
    for frs in fitter_results:
        costs = [fr.costs() for fr in frs]
        mean_costs.append(np.mean(costs, axis=0))
    all_costs.append(mean_costs)
    
all_costs = np.asarray(all_costs)
x_values = xrange(0, fr.n_iters)

In [22]:
n = 0

plot(x_values, all_costs[:, n].T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Iteration')
ylabel('Mean Normalized Cost')


Out[22]:
<matplotlib.text.Text at 0x7ff76cf9ab50>

Graph 7


In [23]:
n = 0

errors = [[fr.initial_error() for fr in results[0][n]]]
for fitter_results in results:
    errors.append([fr.final_error() for fr in fitter_results[n]])

In [24]:
from menpofit.visualize import plot_ced


legend_entries2 = ['Ini'] + legend_entries

plot_ced(errors, legend_entries=legend_entries2)


Fitting Statistics


In [25]:
from __future__ import division

print '\t', 'Mean \t', 'STD \t', 'Median \t', 'Convergence \t'

for err, method in zip(errors, legend_entries2):
    print method, '\t', 
    print np.round(np.mean(err), decimals=4), '\t', 
    print np.round(np.std(err), decimals=4), '\t', 
    print np.round(np.median(err), decimals=4), '\t',
    
    c = 0
    for e, ini_e in zip(err, errors[0]):
        if e < ini_e:
            c+=1
        
    print np.round(c / len(err), decimals=4)


	Mean 	STD 	Median 	Convergence 	
Ini 	0.0892 	0.0262 	0.0884 	0.0
SIC 	0.0349 	0.0224 	0.0286 	0.9852
AIC 	0.0355 	0.0234 	0.0288 	0.9842
SSC 	0.0336 	0.0207 	0.0279 	0.9871
SBC 	0.0335 	0.0204 	0.0281 	0.9881
ASC 	0.0345 	0.0214 	0.0283 	0.9901
ABC 	0.0343 	0.0214 	0.0284 	0.9881
BSC 	0.0326 	0.0177 	0.0274 	0.9931