agent = agent[0] - min_y, agent[1] - min_x
items = [((y - min_y, x - min_x), p) for (y, x), p in items]
path = [(y - min_y, x - min_x) for (y, x) in path]

# print size_x
# exit()
import numpy as np
np.set_printoptions(edgeitems=3200, linewidth=10000, precision=3)
world = ItemPickWorld.ItemPickWorld()
world.items = items
# world.map = np.zeros((32, 32))
world.map = np.zeros((size_y, size_x))
world.agent = agent
world.path = path
world.s = world.map.shape[0] * world.map.shape[1]
world.eval_id = eval_id

import pickle
# pickle.dump(world, open("dump/sample_world_" + str(eval_id) + ".pkl", "w"))
pickle.dump(
    world, open("../experiment/dump/sample_world_" + str(eval_id) + ".pkl",
                "w"))

exit()

import graph_world2
graph_world2.GraphWorld(world, 0.5)

world.show_world(path, save=True)
# world.show_world([], save=True)
Beispiel #2
0

prob_data = [{k: v[1] for k, v in u.viewitems()} for u in format_data]
human = np.zeros((len(prob_data), 10, 4))
for i, d in enumerate(prob_data):
    for k, v in d.viewitems():
        human[i][k - 1] = v

# top = np.zeros((11, 10, 4))
bottom = np.zeros((11, 10, 4))
# bottom2 = np.zeros((11, 10, 4))
for beta in range(0, 11):
    for eval_id in range(1, 11):
        world = pickle.load(
            open("dump/sample_world_" + str(eval_id) + ".pkl", "r"))
        wb = graph_world2.GraphWorld(world, 0.4, 0.1 * beta)
        _, b, _ = wb.check_action(wb.base_action)
        bottom[beta, eval_id - 1] = b[answer_index[eval_id]]
    bottom[beta] = bottom[beta] / np.sum(bottom[beta], axis=1, keepdims=True)

print bottom
# for h in human:
#     values = []
#     for beta in range(0, 11):
#         values.append(scipy.stats.pearsonr(h.flatten(), bottom[beta].flatten())[0])
#     print np.argmax(np.array(values))

task_bb = []
task_b = []
task_t = []
for h in human:
Beispiel #3
0
}

top = np.zeros((10, 4))
bottom = np.zeros((10, 4))
bottom2 = np.zeros((10, 4))

# for eval_id in range(1, 11):
for eval_id in range(1, 11):
    # for eval_id in [5]:
    #     for beta in range(10):
    #     for beta in [5]:
    for beta in [4]:
        #     for beta in [5]:
        world = pickle.load(
            open("dump/sample_world_" + str(eval_id) + ".pkl", "r"))
        wb = graph_world2.GraphWorld(world, 0.5, 0.5)
        _, b, _ = wb.check_action(wb.base_action)
        # wti graph_world2.GraphWorld(world, 0.5)
        # world.show_world([], True)
        # exit()
        # wt= graph_world2.GraphWorld(world, beta*0.1)
        # wb= graph_world2.GraphWorld(world, beta*0.1)
        # wt= graph_world2.GraphWorld(world, 0.4)
        # wb= graph_world2.GraphWorld(world, 0.4, 0.7)
        # wb2= graph_world2.GraphWorld(world, 0.5)
        wt = graph_world2.GraphWorld(world, 0.5)
        wb = graph_world2.GraphWorld(world, 0.5, 0.5)
        wb2 = graph_world2.GraphWorld(world, 0.5)
        # t, _ = wt.check_action(wt.base_action)
        t, _, _ = wt.check_action(wt.base_action)
        _, b, _ = wb.check_action(wb.base_action)
                        bottom="off",
                        left="off")
        plt.gca().set_aspect('equal', adjustable='box')
        if save:
            # plt.savefig("data/eval_" + str(self.eval_id) + "/stimuli.jpg", bbox_inches="tight")
            plt.savefig("data/eval_" + str(self.eval_id) + "/stimuli.eps",
                        bbox_inches="tight",
                        format="eps",
                        str=s)
        # plt.show()


if __name__ == '__main__':
    world = ItemPickWorld()
    import graph_world2
    graph = graph_world2.GraphWorld(world)
    exit()
    world.show_world([
        (1, 1),
        (1, 2),
        (1, 3),
        (1, 4),
        (2, 4),
        (3, 4),
        (4, 4),
        (5, 4),
        (6, 4),
        (7, 4),
        (8, 4),
        (9, 4),
        (10, 4),