示例#1
0
def plot_scaling_log(plt_df: pd.DataFrame,
                     sweep_vars: Optional[Sequence[str]] = None,
                     with_baseline=True) -> gg.ggplot:
    """Plot scaling of learning time against exponential baseline."""
    p = _base_scaling(plt_df, sweep_vars, with_baseline)
    p += gg.scale_x_log10(breaks=[5, 10, 20, 50])
    p += gg.scale_y_log10(breaks=[100, 300, 1000, 3000, 10000, 30000])
    p += gg.xlab('deep sea problem size (log scale)')
    p += gg.ylab('#episodes until < 90% bad episodes (log scale)')
    return plotting.facet_sweep_plot(p, sweep_vars)
示例#2
0
def plot_scaling(plt_df: pd.DataFrame,
                 sweep_vars: Sequence[Text] = None,
                 with_baseline: bool = True) -> gg.ggplot:
    """Plot scaling of learning time against exponential baseline."""
    p = _base_scaling(plt_df, sweep_vars, with_baseline)
    p += gg.xlab('deep sea problem size')
    p += gg.ylab('#episodes until < 90% bad episodes')
    if with_baseline:
        max_steps = np.minimum(NUM_EPISODES, plt_df.episode.max())
        p += gg.coord_cartesian(ylim=(0, max_steps))
    return plotting.facet_sweep_plot(p, sweep_vars)
示例#3
0
def plot_regret(df_in: pd.DataFrame,
                sweep_vars: Sequence[Text] = None) -> gg.ggplot:
    """Plot average regret of deep_sea through time by size."""
    df = df_in.copy()
    df = df[df['size'].isin([10, 20, 30, 40, 50])]
    df['avg_bad'] = df.total_bad_episodes / df.episode
    df['size'] = df['size'].astype('category')
    p = (
        gg.ggplot(df[df.episode <= NUM_EPISODES]) +
        gg.aes('episode', 'avg_bad', group='size', colour='size') +
        gg.geom_line(size=2, alpha=0.75) + gg.geom_hline(
            gg.aes(yintercept=0.99), linetype='dashed', alpha=0.4, size=1.75) +
        gg.geom_hline(gg.aes(yintercept=0.0), alpha=0)  # axis hack
        + gg.ylab('average bad episodes') +
        gg.scale_colour_manual(values=plotting.FIVE_COLOURS))
    return plotting.facet_sweep_plot(p, sweep_vars)
示例#4
0
def plot_scale(df: pd.DataFrame,
               sweep_vars: Sequence[str] = None) -> gg.ggplot:
    """Plots the best episode observed by height_threshold."""
    df = cp_swingup_preprocess(df_in=df)

    group_vars = ['height_threshold']
    if sweep_vars:
        group_vars += sweep_vars
    plt_df = df.groupby(group_vars)['best_episode'].max().reset_index()

    p = (
        gg.ggplot(plt_df) +
        gg.aes(x='factor(height_threshold)',
               y='best_episode',
               colour='best_episode > {}'.format(GOOD_EPISODE)) +
        gg.geom_point(size=5, alpha=0.8) +
        gg.scale_colour_manual(values=['#d73027', '#313695']) +
        gg.geom_hline(gg.aes(yintercept=0.0), alpha=0)  # axis hack
        + gg.scale_x_discrete(breaks=[0, 0.25, 0.5, 0.75, 1.0]) +
        gg.ylab('best return in first {} episodes'.format(NUM_EPISODES)) +
        gg.xlab('height threshold'))
    return plotting.facet_sweep_plot(p, sweep_vars)