Esempio n. 1
0
def plot_trial(trial_spec, info_space):
    '''Plot the trial graph, 1 pane: mean and error envelope of reward graphs from all sessions. Each aeb_df gets its own color'''
    prepath = util.get_prepath(trial_spec, info_space)
    predir = util.prepath_to_predir(prepath)
    session_datas = session_datas_from_file(predir, trial_spec,
                                            info_space.get('trial'))

    aeb_count = len(session_datas[0])
    palette = get_palette(aeb_count)
    fig = None
    for idx, (a, e, b) in enumerate(session_datas[0]):
        aeb = (a, e, b)
        aeb_str = f'{a}{e}{b}'
        color = palette[idx]
        aeb_rewards_df = gather_aeb_rewards_df(aeb, session_datas)
        aeb_fig = build_aeb_reward_fig(aeb_rewards_df, aeb_str, color)
        if fig is None:
            fig = aeb_fig
        else:
            fig.data.extend(aeb_fig.data)
    fig.layout.update(
        title=f'trial graph: {trial_spec["name"]} t{info_space.get("trial")}',
        width=500,
        height=600)
    viz.plot(fig)
    return fig
Esempio n. 2
0
def session_data_dict_for_dist(spec, info_space):
    '''Method to retrieve session_datas (fitness df, so the same as session_data_dict above) when a trial with distributed sessions is done, to avoid messy multiprocessing data communication'''
    prepath = util.get_prepath(spec, info_space)
    predir = util.prepath_to_predir(prepath)
    session_datas = session_data_dict_from_file(predir, info_space.get('trial'))
    session_datas = [session_datas[k] for k in sorted(session_datas.keys())]
    return session_datas
Esempio n. 3
0
def save_experiment_data(spec, info_space, experiment_df, experiment_fig):
    '''Save the experiment data: best_spec, experiment_df, experiment_graph.'''
    prepath = util.get_prepath(spec, info_space, unit='experiment')
    logger.info(f'Saving experiment data to {prepath}')
    util.write(experiment_df, f'{prepath}_experiment_df.csv')
    viz.save_image(experiment_fig, f'{prepath}_experiment_graph.png')
    # zip for ease of upload
    predir = util.prepath_to_predir(prepath)
    shutil.make_archive(predir, 'zip', predir)
    logger.info(f'All experiment data zipped to {predir}.zip')
Esempio n. 4
0
def plot_trial(trial_spec, info_space):
    '''Plot the trial graph, 1 pane: mean and error envelope of reward graphs from all sessions. Each aeb_df gets its own color'''
    prepath = util.get_prepath(trial_spec, info_space)
    predir = util.prepath_to_predir(prepath)
    session_datas = session_datas_from_file(predir, trial_spec, info_space.get('trial'))

    aeb_count = len(session_datas[0])
    palette = get_palette(aeb_count)
    fig = None
    for idx, (a, e, b) in enumerate(session_datas[0]):
        aeb = (a, e, b)
        aeb_str = f'{a}{e}{b}'
        color = palette[idx]
        aeb_rewards_df = gather_aeb_rewards_df(aeb, session_datas)
        aeb_fig = build_aeb_reward_fig(aeb_rewards_df, aeb_str, color)
        if fig is None:
            fig = aeb_fig
        else:
            fig.data.extend(aeb_fig.data)
    fig.layout.update(title=f'trial graph: {trial_spec["name"]} t{info_space.get("trial")}', width=500, height=600)
    viz.plot(fig)
    return fig