In [1]:
    
%matplotlib inline
%pylab inline
    
    
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]
sic, sfc = [], []
aic, afc = [], []
bic, bfc, pic = [], [], []
for n in noise_std:
    sic.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_SIC_' + db + '_' + str(n)))
    sfc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_SFC_' + db + '_' + str(n)))
    
    aic.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_AIC_' + db + '_' + str(n)))
    afc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_AFC_' + db + '_' + str(n)))
    
    
    bic.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_BIC_' + db + '_' + str(n)))
    bfc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_BFC_' + db + '_' + str(n)))
    pic.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_PIC_' + db + '_' + str(n)))
    
results = [sic, sfc, 
           aic, afc, 
           bic, bfc, pic]
legend_entries = ['SIC', 'SFC', 
                  'AIC', 'AFC',  
                  'BIC', 'BFC', 'PIC']
    
In [3]:
    
results = [sic, sfc, 
           aic, afc]
legend_entries = ['SIC', 'SFC', 
                  'AIC', 'AFC']
    
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_errors.append(np.mean(errors))
    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]:
    
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 = range(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]:
    
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 = range(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 Point-to-Point Error')
    
    Out[9]:
    
In [10]:
    
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 [11]:
    
from menpofit.visualize import plot_ced
legend_entries2 = ['Ini'] + legend_entries
plot_ced(errors, legend_entries=legend_entries2)
    
    
In [12]:
    
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)