<jupyter_start><jupyter_text>Prediction Evaluation Print model names<jupyter_code>print_filelist(m_flist_tt)<jupyter_output><empty_output><jupyter_text>Predict on models<jupyter_code>#part_x_M027, pos_ids = get_pos_IDs(part['NFCHOA_M027'],ID_ref)
#part_x_R006, _ = get_pos_IDs(part['NFCHOA_R006'],ID_ref)

params_t = params.copy()
params_t['batch_size'] = 1000

params_t_nsc = params_nsc.copy()
params_t_nsc['batch_size'] = 1000

params_t_nic = create_test_params(feat[cn[:64]], targ, par, batch_size=1000, shuffle=False)

def model_pred_pos(model, part, params, ID_ref):
    """Returns list of ndarrays of predictions on model based on test partition per position."""
    part_x, pos_ids = get_pos_IDs(part,ID_ref)
    b_gen = []
    pred = []
    y = []
    for j in range(len(part_x)):
        b_gen.append(DataGenerator_raw(part_x[j], **params))
        pred.append(model.predict_generator(b_gen[j], verbose=0, use_multiprocessing=True, workers=4))
        y.append(get_y_gen(b_gen[j]))
    return pred, y
pred_R006 = {}
pred_M027 = {}
y_R006 = {}
y_M027 = {}
for i,md in enumerate(m_flist_tt):
    if 'no-ic' in md:
        params_tmp = params_t_nic
    elif 'nsc' in md:
        params_tmp = params_t_nsc
    else:
        params_tmp = params_t    
    
    pred_R006[md], y_R006[md] = model_pred_pos(m_tt[i] , part['NFCHOA_R006'], params_tmp, ID_ref)
    pred_M027[md], y_M027[md] = model_pred_pos(m_tt[i] , part['NFCHOA_M027'], params_tmp, ID_ref)
    #print(i)
k = list(pred_M027.keys())<jupyter_output><empty_output><jupyter_text>Generate Plots<jupyter_code># generate plots
%matplotlib
# all positions overview
for name in k[11:12]:
    model_name, loss_name, tdata, special, bs, _ = get_model_info(name)
    f1 = plot_locaz_all(pred_R006[name],
                        l=True,
                        title='Model: {}{} | Loss: {} | Test-Data: {}'.format(model_name, special, loss_name, 'NFCHOA_R006'))
    #f2 = plot_locaz_all(pred_M027[name],
    #                    l=True,
    #                    title='Model: {}{} | Loss: {} | Test-Data: {}'.format(model_name, special, loss_name, 'NFCHOA_M027'))
# individual positions incl. gt comparison
%matplotlib

m_idx = 12
pos_idx = 0

#model_name, loss_name, tdata, special, bs, _ = get_model_info(k[m_idx])

# manually wrap angles
def wrap(a):
    for i in range(len(a)):
        if a[i] > 180:
            a[i] = a[i]-360
        elif a[i] < -180:
            a[i] = a[i]+360
    return a

#title = 'Model: {}{} | Loss: {} | Test-Data: {}\n Position: {}'.format(model_name, special, loss_name, 'NFCHOA_M027', pos_idx)
f1, ax_p, ax_y = plot_locaz(wrap(pred_M027[k[m_idx]][pos_idx]), y_M027[k[m_idx]][pos_idx], l=True)
#f.suptitle(title, fontsize='x-large')
lines = (ax_p.get_children()[:1][0],ax_y.get_children()[:1][0],ax_p.get_children()[:][1],ax_p.get_children()[:][2],ax_p.get_children()[:][4])
#f.legend(lines, ('predictions', 'human / gt', 'mean over subjects/repititions at 0° head rotation', '± 180°','± 180°'))

#title = 'Model: {}{} | Loss: {} | Test-Data: {}\n Position: {}'.format(model_name, special, loss_name, 'NFCHOA_R006', pos_idx)
f2, ax_p, ax_y = plot_locaz(wrap(pred_R006[k[m_idx]][pos_idx]), y_R006[k[m_idx]][pos_idx], l=True)
#f.suptitle(title, fontsize='x-large')
lines = (ax_p.get_children()[:1][0],ax_y.get_children()[:1][0],ax_p.get_children()[:][1],ax_p.get_children()[:][2],ax_p.get_children()[:][4])
#f.legend(lines, ('predictions', 'human / gt', 'mean over subjects/repititions at 0° head rotation', '± 180°','± 180°'))
f1.set_size_inches(10.5, 5)
f1.savefig('f1.png', dpi=200)
f2.set_size_inches(10.5, 5)
f2.savefig('f2.png', dpi=200)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup