In [17]:
import cPickle

# PARAMS
log_dir = "/home/sforesti/avakas/scratch/sforestier001/logs/PLAY2017/2017-12-12_18-00-17-play_tol02"
config_list = ["PC", "C08T05", "C08T2", "C03T05", "C03T2"]

data_competence = {}
for config_name in config_list:
    print config_name
    filename = log_dir + '/results/' + config_name + '_competence.pickle'
    with open(filename, 'r') as f:
        data_competence[config_name] = cPickle.load(f)[config_name]
        
        
vocal_tol = 0.4
toy_tol = 0.2
hand_lim = 0.5 + toy_tol / 2.
tool_lim = 0.75 + toy_tol / 2.

data_vocal = {}
for config_name in config_list:
    print config_name
    filename = log_dir + '/results/' + config_name + '_vocal.pickle'
    with open(filename, 'r') as f:
        data_vocal[config_name] = cPickle.load(f)[config_name]


PC
C08T05
C08T2
C03T05
C03T2
PC
C08T05
C08T2
C03T05
C03T2

In [18]:
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
%matplotlib inline

n_trial = 50
n_goals = 100
trial_list = range(1,n_trial + 1)

In [19]:
def maps(config_name):

    bins = 100

    map_comp = np.zeros((bins, bins))
    map_hand = np.zeros((bins, bins))
    map_tool = np.zeros((bins, bins))
    map_vocal = np.zeros((bins, bins))
    
    map_succ = np.zeros((bins, bins))
    map_succ_hand = np.zeros((bins, bins))
    map_succ_tool = np.zeros((bins, bins))
    map_succ_vocal = np.zeros((bins, bins))
    tot_succ = np.zeros((bins, bins))

    min_2d = [-1.25,  -1.25]
    max_2d = [1.25,  1.25]

    def real2map(x, y):
        i = int((x - min_2d[0]) / (max_2d[0] - min_2d[0]) * 100.)
        j = int((y - min_2d[0]) / (max_2d[0] - min_2d[0]) * 100.)
        i = max(0, min(i, 99))
        j = max(0, min(j, 99))
        return i, j

    #trial_list = [1]
    for trial in trial_list:
        if data_competence[config_name][trial].has_key("eval_results"):
            for region in [1, 2, 3]:
                for gi in range(n_goals):
                    for toy in ["toy1", "toy2", "toy3"]:
                        # Test only toys for which the agent produced the name at least once
                        #print data_vocal[config_name][trial]["errors"][-1]
                        if data_vocal[config_name][trial]["errors"][-1][data_vocal[config_name][trial]["human_sounds"][int(toy[-1]) - 1]] < vocal_tol:
                            x, y = data_competence[config_name][trial]["eval_results"][region][gi][toy]["toy_pos"]
                            i, j = real2map(x, y)
                            map_comp[i, j] += data_competence[config_name][trial]["eval_results"][region][gi][toy]["comp_error"]
                            if data_competence[config_name][trial]["eval_results"][region][gi][toy]["arm_dist"] < data_competence[config_name][trial]["eval_results"][region][gi][toy]["diva_dist"]:
                                if data_competence[config_name][trial]["eval_results"][region][gi][toy]["tool"]:
                                    map_tool[i, j] += 1
                                    if data_competence[config_name][trial]["eval_results"][region][gi][toy]["reached"]:
                                        map_succ_tool[i, j] += 1
                                else:
                                    map_hand[i, j] += 1
                                    if data_competence[config_name][trial]["eval_results"][region][gi][toy]["reached"]:
                                        map_succ_hand[i, j] += 1
                            else:      
                                map_vocal[i, j] += 1
                                if data_competence[config_name][trial]["eval_results"][region][gi][toy]["reached"]:
                                    map_succ_vocal[i, j] += 1

                            if data_competence[config_name][trial]["eval_results"][region][gi][toy]["reached"]:
                                map_succ[i, j] += 1
                            tot_succ[i, j] += 1
                            

    for i in range(bins):
        for j in range(bins):
            map_succ_hand[i, j] = float(map_succ_hand[i, j]) / map_hand[i, j]
            map_succ_tool[i, j] = float(map_succ_tool[i, j]) / map_tool[i, j]
            map_succ_vocal[i, j] = float(map_succ_vocal[i, j]) / map_vocal[i, j]
            map_succ[i, j] = float(map_succ[i, j]) / tot_succ[i, j]
            
    for i in range(bins):
        for j in range(bins):
            n = map_hand[i, j] + map_tool[i, j] + map_vocal[i, j]
            if n > 0:
                map_comp[i, j] /= n
            else:
                map_comp[i, j] = -1

    map_total = map_hand + map_tool + map_vocal

    for i in range(bins):
        for j in range(bins):
            if map_total[i, j]:
                map_hand[i, j] /= map_total[i, j]
                map_tool[i, j] /= map_total[i, j]
                map_vocal[i, j] /= map_total[i, j]
            if (i - bins/2.)**2. + (j - bins/2.)**2. > bins*bins/4.:
                map_hand[i, j] = -1
                map_tool[i, j] = -1
                map_vocal[i, j] = -1
                

    x_points = np.linspace(-1., 1., bins)
    y_points = np.linspace(-1., 1., bins)

    pcol = plt.pcolormesh(x_points, y_points, map_comp, vmin=0, vmax=3., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')

    pcol.cmap.set_under('white')

    cb = plt.colorbar()
    #cb.ax.set_yticklabels(["Tool", "", "", "", "", "", "", "", "", "", "Hand"], fontsize = 30)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")

    # GET MOTOR BABBLING ERROR MAP
    import cPickle

    filename = '../data/motor_babbling.pickle'
    with open(filename, 'r') as f:
        map_comp_mb_avg = cPickle.load(f)
    f.close()

    pcol = plt.pcolormesh(x_points, y_points, map_comp_mb_avg, vmin=0, vmax=3., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')

    pcol.cmap.set_under('white')

    cb = plt.colorbar()
    #cb.ax.set_yticklabels(["Tool", "", "", "", "", "", "", "", "", "", "Hand"], fontsize = 30)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")
        
    
    plt.clf()
    
    # NORMALIZE COMPETENCE MAP WITH MOTOR BABBLING MAP
    map_comp_norm = np.zeros((bins, bins))

    for i in range(bins):
        for j in range(bins):
            if map_comp[i, j] < 0.:
                map_comp_norm[i, j] = -1.
            elif np.isnan(map_comp_mb_avg[i, j]):
                map_comp_norm[i, j] = 200.
            else:
                map_comp_norm[i, j] = max(0., 1. - map_comp[i, j] / map_comp_mb_avg[i, j])

    # the few missing points become avg of neighbors
    for i in range(bins-1):
        for j in range(bins-1):
            if map_comp_norm[i, j] == -1. and (i-bins/2.) * (i-bins/2.) + (j-bins/2.) * (j-bins/2.) < bins * bins / 4.:
                map_comp_norm[i, j] = np.mean([map_comp_norm[i+1, j],
                                             map_comp_norm[i-1, j],
                                             map_comp_norm[i, j+1],
                                             map_comp_norm[i, j-1]])

    x_points = np.linspace(-1., 1., bins)
    y_points = np.linspace(-1., 1., bins)





    plt.rc('text', usetex=True)
    plt.rc('font', family='serif')

    pcol = plt.pcolormesh(x_points, y_points, 100.* map_comp_norm, vmin=0., vmax=100., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')
    pcol.cmap.set_under('white')
    pcol.cmap.set_over('grey')

    cb = plt.colorbar()
    cb.ax.set_yticklabels(["$0\%$", "", "$20\%$", "", "$40\%$", "", "$60\%$", "", "$80\%$", "", "$100\%$"], fontsize = 16)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")   

    ax = plt.axes()
    ax.set_aspect(1)
    theta = np.linspace(-np.pi, np.pi, 200)
    plt.plot(hand_lim * np.sin(theta), hand_lim * np.cos(theta), 'k', lw=3)
    plt.plot(tool_lim * np.sin(theta), tool_lim * np.cos(theta), 'k', lw=3)


    plt.xlabel("X", fontsize=20)
    plt.ylabel("Y", fontsize=20)

    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)

    plt.axhline(-1, color='k')
    plt.axvline(-1, color='k')
    plt.axhline(1, color='k')
    plt.axvline(1, color='k')

    plt.savefig('../figs/fig_competence_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')
    
    
    #print np.mean(map_comp_norm[map_comp_norm>0.])
    plt.clf()
    
    pcol = plt.pcolormesh(x_points, y_points, 100.* map_hand, vmin=0., vmax=100., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')
    pcol.cmap.set_under('white')
    pcol.cmap.set_over('white')

    cb = plt.colorbar()
    cb.ax.set_yticklabels(["$0\%$", "", "$20\%$", "", "$40\%$", "", "$60\%$", "", "$80\%$", "", "$100\%$"], fontsize = 16)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")   

    ax = plt.axes()
    ax.set_aspect(1)
    theta = np.linspace(-np.pi, np.pi, 200)
    plt.plot(hand_lim * np.sin(theta), hand_lim * np.cos(theta), 'k', lw=3)
    plt.plot(tool_lim * np.sin(theta), tool_lim * np.cos(theta), 'k', lw=3)


    plt.xlabel("X", fontsize=20)
    plt.ylabel("Y", fontsize=20)

    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)

    plt.axhline(-1, color='k')
    plt.axvline(-1, color='k')
    plt.axhline(1, color='k')
    plt.axvline(1, color='k')

    plt.savefig('../figs/fig_strategy_hand_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')
    
    plt.clf()
    pcol = plt.pcolormesh(x_points, y_points, 100.* map_succ_hand, vmin=0., vmax=100., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')
    pcol.cmap.set_under('white')
    pcol.cmap.set_over('white')
    cb = plt.colorbar()
    cb.ax.set_yticklabels(["$0\%$", "", "$20\%$", "", "$40\%$", "", "$60\%$", "", "$80\%$", "", "$100\%$"], fontsize = 16)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")   
    ax = plt.axes()
    ax.set_aspect(1)
    theta = np.linspace(-np.pi, np.pi, 200)
    plt.plot(hand_lim * np.sin(theta), hand_lim * np.cos(theta), 'k', lw=3)
    plt.plot(tool_lim * np.sin(theta), tool_lim * np.cos(theta), 'k', lw=3)
    plt.xlabel("X", fontsize=20)
    plt.ylabel("Y", fontsize=20)
    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)
    plt.axhline(-1, color='k')
    plt.axvline(-1, color='k')
    plt.axhline(1, color='k')
    plt.axvline(1, color='k')
    plt.savefig('../figs/fig_success_hand_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')  
    
    plt.clf()
    pcol = plt.pcolormesh(x_points, y_points, 100.* map_succ_tool, vmin=0., vmax=100., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')
    pcol.cmap.set_under('white')
    pcol.cmap.set_over('white')
    cb = plt.colorbar()
    cb.ax.set_yticklabels(["$0\%$", "", "$20\%$", "", "$40\%$", "", "$60\%$", "", "$80\%$", "", "$100\%$"], fontsize = 16)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")   
    ax = plt.axes()
    ax.set_aspect(1)
    theta = np.linspace(-np.pi, np.pi, 200)
    plt.plot(hand_lim * np.sin(theta), hand_lim * np.cos(theta), 'k', lw=3)
    plt.plot(tool_lim * np.sin(theta), tool_lim * np.cos(theta), 'k', lw=3)
    plt.xlabel("X", fontsize=20)
    plt.ylabel("Y", fontsize=20)
    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)
    plt.axhline(-1, color='k')
    plt.axvline(-1, color='k')
    plt.axhline(1, color='k')
    plt.axvline(1, color='k')
    plt.savefig('../figs/fig_success_tool_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')   
    
    plt.clf()
    pcol = plt.pcolormesh(x_points, y_points, 100.* map_succ_vocal, vmin=0., vmax=100., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')
    pcol.cmap.set_under('white')
    pcol.cmap.set_over('white')
    cb = plt.colorbar()
    cb.ax.set_yticklabels(["$0\%$", "", "$20\%$", "", "$40\%$", "", "$60\%$", "", "$80\%$", "", "$100\%$"], fontsize = 16)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")   
    ax = plt.axes()
    ax.set_aspect(1)
    theta = np.linspace(-np.pi, np.pi, 200)
    plt.plot(hand_lim * np.sin(theta), hand_lim * np.cos(theta), 'k', lw=3)
    plt.plot(tool_lim * np.sin(theta), tool_lim * np.cos(theta), 'k', lw=3)
    plt.xlabel("X", fontsize=20)
    plt.ylabel("Y", fontsize=20)
    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)
    plt.axhline(-1, color='k')
    plt.axvline(-1, color='k')
    plt.axhline(1, color='k')
    plt.axvline(1, color='k')
    plt.savefig('../figs/fig_success_vocal_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')
    
    plt.clf()
    pcol = plt.pcolormesh(x_points, y_points, 100.* map_tool, vmin=0., vmax=100., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')
    pcol.cmap.set_under('white')
    pcol.cmap.set_over('white')

    cb = plt.colorbar()
    cb.ax.set_yticklabels(["$0\%$", "", "$20\%$", "", "$40\%$", "", "$60\%$", "", "$80\%$", "", "$100\%$"], fontsize = 16)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")   

    ax = plt.axes()
    ax.set_aspect(1)
    theta = np.linspace(-np.pi, np.pi, 200)
    plt.plot(hand_lim * np.sin(theta), hand_lim * np.cos(theta), 'k', lw=3)
    plt.plot(tool_lim * np.sin(theta), tool_lim * np.cos(theta), 'k', lw=3)


    plt.xlabel("X", fontsize=20)
    plt.ylabel("Y", fontsize=20)

    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)

    plt.axhline(-1, color='k')
    plt.axvline(-1, color='k')
    plt.axhline(1, color='k')
    plt.axvline(1, color='k')

    plt.savefig('../figs/fig_strategy_tool_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')
    
    plt.clf()
    
    pcol = plt.pcolormesh(x_points, y_points, 100.* map_vocal, vmin=0., vmax=100., linewidth=0, cmap="jet")  
    pcol.set_rasterized(True)      
    pcol.set_edgecolor('face')
    pcol.cmap.set_under('white')
    pcol.cmap.set_over('white')

    cb = plt.colorbar()
    cb.ax.set_yticklabels(["$0\%$", "", "$20\%$", "", "$40\%$", "", "$60\%$", "", "$80\%$", "", "$100\%$"], fontsize = 16)
    cb.solids.set_rasterized(True)
    cb.solids.set_edgecolor("face")   

    ax = plt.axes()
    ax.set_aspect(1)
    theta = np.linspace(-np.pi, np.pi, 200)
    plt.plot(hand_lim * np.sin(theta), hand_lim * np.cos(theta), 'k', lw=3)
    plt.plot(tool_lim * np.sin(theta), tool_lim * np.cos(theta), 'k', lw=3)


    plt.xlabel("X", fontsize=20)
    plt.ylabel("Y", fontsize=20)

    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)

    plt.axhline(-1, color='k')
    plt.axvline(-1, color='k')
    plt.axhline(1, color='k')
    plt.axvline(1, color='k')

    plt.savefig('../figs/fig_strategy_vocal_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')
    
    plt.clf()
    
    mean_hand = np.zeros(50)
    count_hand = np.zeros(50)
    for i in range(bins):
        for j in range(bins):
            d = int(np.sqrt((i-bins/2)*(i-bins/2) + (j-bins/2)*(j-bins/2)))
            if d < 50:
                mean_hand[d] += map_hand[i, j]
                count_hand[d] += 1
    mean_hand = mean_hand / count_hand

    mean_tool = np.zeros(50)
    count_tool = np.zeros(50)
    for i in range(bins):
        for j in range(bins):
            d = int(np.sqrt((i-bins/2)*(i-bins/2) + (j-bins/2)*(j-bins/2)))
            if d < 50:
                mean_tool[d] += map_tool[i, j]
                count_tool[d] += 1
    mean_tool = mean_tool / count_tool

    mean_vocal = np.zeros(50)
    count_vocal = np.zeros(50)
    for i in range(bins):
        for j in range(bins):
            d = int(np.sqrt((i-bins/2)*(i-bins/2) + (j-bins/2)*(j-bins/2)))
            if d < 50:
                mean_vocal[d] += map_vocal[i, j]
                count_vocal[d] += 1
    mean_vocal = mean_vocal / count_vocal

    #print "hand", 100.*mean_hand
    #print "tool", 100.*mean_tool
    #print "vocal", 100.*mean_vocal
    mean_total = mean_hand + mean_tool + mean_vocal
    mean_hand /= mean_total
    mean_tool /= mean_total
    mean_vocal /= mean_total

    x = np.linspace(0., max_2d[0], 50)

    plt.plot(x, 100.*mean_hand, "r", lw=3, label="Hand")
    plt.plot(x, 100.*mean_tool, "g", lw=3, label="Tool")
    plt.plot(x, 100.*mean_vocal, "b", lw=3, label="Vocal")

    #print mean_total
    #print mean_hand[-1] + mean_tool[-1] + mean_vocal[-1]
    #print "hand", 100.*mean_hand
    #print "tool", 100.*mean_tool
    #print "vocal", 100.*mean_vocal

    legend = plt.legend(frameon=True, fontsize=20)
    plt.xlabel("Distance to center", fontsize=20)
    plt.ylabel("Strategy Use (\%)", fontsize=20)

    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)

    frame = legend.get_frame()
    frame.set_facecolor('1.')
    frame.set_edgecolor('0.')

    plt.plot((hand_lim, hand_lim), (0, 100), 'k--', lw=2)
    plt.plot((tool_lim, tool_lim), (0, 100), 'k--', lw=2)


    plt.savefig('../figs/fig_strategy_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')

    plt.clf()
    
    succ_hand = np.zeros(50)
    count_hand = np.zeros(50)
    for i in range(bins):
        for j in range(bins):
            d = int(np.sqrt((i-bins/2)*(i-bins/2) + (j-bins/2)*(j-bins/2)))
            if d < 50 and not np.isnan(map_succ_hand[i, j]):
                succ_hand[d] += map_succ_hand[i, j]
                count_hand[d] += 1
    succ_hand = succ_hand / count_hand

    succ_tool = np.zeros(50)
    count_tool = np.zeros(50)
    for i in range(bins):
        for j in range(bins):
            d = int(np.sqrt((i-bins/2)*(i-bins/2) + (j-bins/2)*(j-bins/2)))
            if d < 50 and not np.isnan(map_succ_tool[i, j]):
                succ_tool[d] += map_succ_tool[i, j]
                count_tool[d] += 1
    succ_tool = succ_tool / count_tool

    succ_vocal = np.zeros(50)
    count_vocal = np.zeros(50)
    for i in range(bins):
        for j in range(bins):
            d = int(np.sqrt((i-bins/2)*(i-bins/2) + (j-bins/2)*(j-bins/2)))
            if d < 50 and not np.isnan(map_succ_vocal[i, j]):
                succ_vocal[d] += map_succ_vocal[i, j]
                count_vocal[d] += 1
    succ_vocal = succ_vocal / count_vocal
    
    x = np.linspace(0., max_2d[0], 50)

    print map_succ_hand
    print map_succ_tool
    print map_succ_tool
    
    print succ_hand
    print succ_tool
    print succ_vocal
    
    plt.plot(x, 100.*succ_hand, "r", lw=3, label="Hand")
    plt.plot(x, 100.*succ_tool, "g", lw=3, label="Tool")
    plt.plot(x, 100.*succ_vocal, "b", lw=3, label="Vocal")
    legend = plt.legend(frameon=True, fontsize=20)
    plt.xlabel("Distance to center", fontsize=20)
    plt.ylabel("Strategy success (\%)", fontsize=20)

    plt.xticks(fontsize = 16)
    plt.yticks(fontsize = 16)

    frame = legend.get_frame()
    frame.set_facecolor('1.')
    frame.set_edgecolor('0.')

    plt.plot((hand_lim, hand_lim), (0, 100), 'k--', lw=2)
    plt.plot((tool_lim, tool_lim), (0, 100), 'k--', lw=2)


    plt.savefig('../figs/fig_success_' + config_name.replace(".", "") + '.pdf', format='pdf', bbox_inches='tight')

In [20]:
maps("PC")


/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:59: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:60: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:61: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:62: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:438: RuntimeWarning: invalid value encountered in divide
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:458: RuntimeWarning: invalid value encountered in divide
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[ 0.5         0.46359258  0.36231819  0.25806624  0.27555708  0.27493056
  0.2179343   0.30835813  0.29379252  0.41940701  0.37515361  0.41616223
  0.4495614   0.48011034  0.52900433  0.486       0.56350211  0.5443299
  0.48389513  0.50704467  0.41804124  0.41391437  0.23511905  0.16666667
  0.04959677  0.01328502  0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.                 nan         nan
  0.                 nan         nan         nan         nan         nan]
[ 0.47826087  0.55755541  0.43229167  0.40736111  0.39080087  0.3912037
  0.46547619  0.37310167  0.21594203  0.22587719  0.32074074  0.5234375
  0.34259259  0.45987654  0.33823529  0.3974359   0.38657407  0.3968254
  0.43333333  0.275       0.31746032  0.35606061  0.42708333  0.35680751
  0.33553459  0.26962834  0.28007812  0.25238095  0.24457071  0.28339002
  0.2170434   0.16126163  0.089214    0.05342857  0.00308642  0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.        ]
[ 1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.                 nan  1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          0.98846154  0.99025974  0.98648649  0.99275362
  0.98850575  0.99378882  0.98529412  0.99201597  0.98824786  0.99592391
  0.99127907  0.99421965  0.97794118]

In [21]:
maps("C03T05")


/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:59: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:60: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:61: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:62: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:438: RuntimeWarning: invalid value encountered in divide
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:458: RuntimeWarning: invalid value encountered in divide
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[ 0.26923077  0.36465064  0.33738653  0.37443737  0.31344697  0.26625
  0.30940256  0.27844742  0.30274034  0.38525641  0.36054945  0.43918813
  0.37162162  0.46831502  0.50905999  0.51964286  0.57242798  0.57680412
  0.469       0.48235714  0.43177083  0.38685015  0.25759076  0.15064103
  0.04002625  0.01141553  0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.                 nan
         nan         nan         nan         nan         nan         nan]
[ 0.5         0.56828704  0.52261905  0.45285714  0.40010823  0.35982906
  0.29375     0.45324074  0.46910569  0.28070175  0.37850877  0.22149123
  0.34496124  0.3537415   0.24561404  0.46875     0.35353535  0.48290598
  0.31034483  0.57207207  0.515       0.53930818  0.29084967  0.46038251
  0.40235507  0.30343915  0.25301837  0.29444444  0.2749359   0.24663561
  0.18575949  0.17476738  0.08020833  0.0468254   0.00292398  0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.        ]
[ 1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.                 nan  1.          1.
  1.                 nan  1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  0.97222222  0.98421053  0.98295455  0.99122807  0.99043716  1.
  0.98287671  0.97286822  0.99603175  0.95454545  0.95578231  1.
  0.98449612  0.97130243  0.99576271]

In [22]:
maps("C03T2")


/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:59: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:60: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:61: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:62: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:438: RuntimeWarning: invalid value encountered in divide
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[ 0.35714286  0.38002011  0.33855607  0.24857058  0.30410203  0.27805802
  0.2945657   0.28418609  0.36666667  0.34009434  0.37727273  0.38918483
  0.41114865  0.46071429  0.43551587  0.56488095  0.55341365  0.52371134
  0.49492063  0.45816327  0.44984568  0.33237295  0.23436578  0.12713864
  0.03091603  0.02068966  0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.                 nan         nan
         nan         nan         nan         nan         nan         nan]
[ 0.5         0.50178571  0.50864448  0.45718254  0.41376812  0.32175926
  0.39247312  0.30416667  0.36805556  0.37936508  0.29311594  0.28294574
  0.28571429  0.49673203  0.37083333  0.41860465  0.41414141  0.3
  0.39583333  0.38679245  0.33333333  0.32993197  0.43        0.49717949
  0.3693019   0.24572511  0.26105911  0.23115224  0.27546296  0.23702742
  0.13211382  0.11460573  0.09036918  0.03278085  0.00578035  0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.        ]
[ 1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  0.875       1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          0.99616858
  1.          0.98623853  0.99586777  0.99647887  0.99386503  0.98861284
  0.97682119  0.96747967  0.98225806  0.97586207  0.99036609  0.99201597
  0.96308244  0.98428571  0.96794872  0.97260274]

In [23]:
maps("C08T05")


/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:59: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:60: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:61: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:62: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:438: RuntimeWarning: invalid value encountered in divide
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[ 0.31746032  0.37196145  0.37611643  0.31200216  0.30028097  0.23872169
  0.26040919  0.27748447  0.3892432   0.31399371  0.35038462  0.36260582
  0.39706458  0.46414566  0.43371429  0.54688147  0.49406115  0.54393091
  0.54097506  0.46993127  0.46366667  0.37277778  0.295       0.10233918
  0.04824561  0.01408451  0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.                 nan  0.                 nan
         nan         nan         nan         nan         nan         nan]
[ 0.4         0.46079365  0.45356952  0.51166667  0.45560732  0.39744898
  0.27749616  0.35615563  0.32986111  0.46064815  0.455       0.41666667
  0.35        0.35947712  0.23863636  0.24358974  0.34883721  0.42857143
  0.38297872  0.54824561  0.30555556  0.38461538  0.44097222  0.3674812
  0.37363316  0.32475083  0.28001253  0.26615385  0.22091954  0.2445628
  0.15755694  0.13759331  0.05839506  0.03138889  0.00290698  0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.        ]
[ 1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          0.9972973
  0.98677249  0.99024823  1.          0.99492386  0.99210526  0.98761905
  0.99038462  0.99378882]

In [24]:
maps("C08T2")


/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:59: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:60: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:61: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:62: RuntimeWarning: invalid value encountered in double_scalars
/usr/local/lib/python2.7/dist-packages/ipykernel/__main__.py:438: RuntimeWarning: invalid value encountered in divide
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[[ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 ..., 
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]
 [ nan  nan  nan ...,  nan  nan  nan]]
[ 0.40384615  0.37837383  0.3776353   0.30801768  0.32926587  0.2978429
  0.31343795  0.34023134  0.29571429  0.3353836   0.45171569  0.29545455
  0.47449139  0.46380952  0.41625514  0.53702515  0.53534137  0.5847352
  0.59304207  0.44589407  0.475       0.44700855  0.37248428  0.12808642
  0.03186275  0.01398601  0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.
         nan         nan         nan         nan         nan         nan]
[ 0.5         0.55362103  0.52450397  0.45416667  0.43030303  0.36752137
  0.31722222  0.22412281  0.29583333  0.35        0.41319444  0.23650794
  0.41056911  0.38333333  0.38963964  0.42380952  0.46190476  0.40909091
  0.32478632  0.3018018   0.37414966  0.375       0.53125     0.47471264
  0.38674521  0.28653163  0.27046784  0.26950758  0.21787491  0.26660923
  0.18364198  0.10481283  0.0867784   0.03277467  0.          0.          0.
  0.          0.          0.          0.          0.          0.          0.
  0.          0.          0.          0.          0.          0.        ]
[ 1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          1.          1.          1.          1.          1.          1.
  1.          0.99315068  1.          1.          0.99494949  1.
  0.99723757  0.99358974  0.99617486  1.          0.99238095  0.9983165
  0.99152542  0.99895833  0.99393939]

In [15]:
import seaborn as sns 

from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes

plt.rc('text', usetex=True)
plt.rc('font', family='serif')


rgb = np.zeros((100, 100, 3))
rgb[:,:,0] = map_hand
rgb[:,:,1] = map_tool
rgb[:,:,2] = map_vocal

#rgb = 1. - rgb
rgb[rgb < 0.] = 1.

plt.figure()
plt.imshow(rgb,interpolation='none')

#for i in range(100):
#    for j in range(100):
#        rgb[i,j,:] = rgb[i,j,:] / max(rgb[i,j,:])

print map_hand[50,50]
print map_tool[50,50]
print map_vocal[50,50]
print rgb[50,50]

theta = np.linspace(-np.pi, np.pi, 200)
plt.plot(50. + 65. * np.sin(theta)/2., 50. + 65. * np.cos(theta)/2, 'k', lw=3)
plt.plot(50. + 85 * np.sin(theta)/2., 50. + 85 * np.cos(theta)/2., 'k', lw=3)

sns.set_style("whitegrid", {'axes.grid' : False})

plt.xlabel("X", fontsize=20)
plt.ylabel("Y", fontsize=20)

plt.xlim([0, 100])
plt.ylim([0, 100])

plt.xticks([0, 25, 50, 75, 100], ["$-1$", "$-0.5$", "$0$", "$0.5$", "$1$"], fontsize = 16)
plt.yticks([0, 25, 50, 75, 100], ["$-1$", "$-0.5$", "$0$", "$0.5$", "$1$"], fontsize = 16)

plt.axhline(0, color='k')
plt.axvline(0, color='k')
plt.axhline(100, color='k')
plt.axvline(100, color='k')

plt.savefig('../figs/fig_strategy.pdf', format='pdf', bbox_inches='tight')


0.691358024691
0.222222222222
0.0864197530864
[ 0.69135802  0.22222222  0.08641975]

In [47]:
config_name = "RMB2"
region = 3

reached = 0
for trial in range(1, 100):
    for gi in range(100):
        for toy in ["toy1", "toy2", "toy3"]:
            if data_competence[config_name][trial]["eval_results"][region][gi][toy]["reached"]:
                reached += 1
print reached


3684