plot_combo.py
def print_single(args, goal_conditioned, name_task, name_plot):
    """Use this for printing a SINGLE item, for single inspection.

    name_task: what we used in code. name_plot: what we want to show in the plot.
    For now, take the max over the iterations (easy to spot check w/curves).
    Actually we have two cases to watch out for (goal conditioned or not)...

    For the table, I'm going to add a few more commands to make it a little easier to copy/paste.
    """
    def get_max(stats_combo, ag_key):
        stat_max = -1
        for key in sorted(stats_combo[ag_key].keys()):
            stat_max = max(stat_max, np.mean(stats_combo[ag_key][key]))
        stat_max *= 100  # We want this in %, in [0,100]
        return stat_max

    # Map from num_demos ---> statistic. Note: DIFFERENT from earlier where we had lists.
    # To be honest this is more scalable as we don't need to wait for all demos to finish.
    # Earlier we appended w/demos, and caused issues if we were missing early demo counts.
    a1, a2, a3, a4, a5, a6, a7 = {}, {}, {}, {}, {}, {}, {}

    # Get relevant directories for each demo, then relevant stats.
    for num_demos in [1, 10, 100, 1000]:
        directories, seeds = get_subdirectories_demos(name_task, num_demos)
        stats_combo = _get_results(name_task, directories, seeds, debug)
        agents = sorted(stats_combo.keys())
        print(f'For task {name_task}, we have results from agents: {agents}')
        if '-transporter' in agents:
            a1[num_demos] = get_max(stats_combo, ag_key='-transporter')
        if '-transporter-goal' in agents:
            a2[num_demos] = get_max(stats_combo, ag_key='-transporter-goal')
        if '-transporter-goal-naive' in agents:
            a3[num_demos] = get_max(stats_combo, ag_key='-transporter-goal-naive')
        if '-gt_state' in agents:
            a4[num_demos] = get_max(stats_combo, ag_key='-gt_state')
        if '-gt_state_2_step' in agents:
            a5[num_demos] = get_max(stats_combo, ag_key='-gt_state_2_step')
        if '-conv_mlp' in agents:
            a6[num_demos] = get_max(stats_combo, ag_key='-gt_state_2_step')
        if '-transporter-goal-snaive' in agents:
            a7[num_demos] = get_max(stats_combo, ag_key='-transporter-goal-snaive')

    print('\nDebugging of which results we have:')
    print(f'keys in a1 (transporter):              {sorted(a1.keys())}')
    print(f'keys in a2 (transporter-goal-split):   {sorted(a2.keys())}')
    print(f'keys in a3 (transporter-goal-naive):   {sorted(a3.keys())} [note should not use this]')
    print(f'keys in a4 (gt_state):                 {sorted(a4.keys())}')
    print(f'keys in a5 (gt_state_2_step):          {sorted(a5.keys())}')
    print(f'keys in a6 (conv_mlp):                 {sorted(a6.keys())}')
    print(f'keys in a7 (transporter-goal-stack): {sorted(a7.keys())}')

    # Manually replace keys with N if we don't have it (I know, I know ...)
    N = ''

    # Use a1 through a5 default dicts. Keys are NUM DEMOS, not tasks.
    s = '\n  \\begin{tabular}{@{}lrrrr}'
    s += '\n  \\toprule'
    s += f'\n  & \multicolumn{{4}}{{c}}{{{name_plot}}} \\\\'
    s += '\n  \cmidrule(lr){2-5}'
    s += '\n  Method & 1 & 10 & 100 & 1000 \\\\'
    s += '\n  \midrule'
    s += (f'\n  GT-State MLP            & {a4[1]:0.1f} & {a4[10]:0.1f} & {a4[100]:0.1f} & {a4[1000]:0.1f} \\\\')
    s += (f'\n  GT-State MLP 2-Step     & {a5[1]:0.1f} & {a5[10]:0.1f} & {a5[100]:0.1f} & {a5[1000]:0.1f} \\\\')
    if goal_conditioned:
        s += (f'\n  Transporter-Goal-Stack  & {a7[1]:0.1f} & {a7[10]:0.1f} & {a7[100]:0.1f} & {a7[1000]:0.1f} \\\\')  # should be a7
        s += (f'\n  Transporter-Goal-Split  & {a2[1]:0.1f} & {a2[10]:0.1f} & {a2[100]:0.1f} & {a2[1000]:0.1f} \\\\')
    else:
        s += (f'\n  Transporter             & {a1[1]:0.1f} & {a1[10]:0.1f} & {a1[100]:0.1f} & {a1[1000]:0.1f} \\\\')
    s += '\n  \\toprule'
    s += '\n  \\end{tabular}'
    print(s)
Use this for printing a SINGLE item, for single inspection.

    name_task: what we used in code. name_plot: what we want to show in the plot.
    For now, take the max over the iterations (easy to spot check w/curves).
    Actually we have two cases to watch out for (goal conditioned or not)...

    For the table, I'm going to add a few more commands to make it a little easier to copy/paste.
    
Use this for printing a SINGLE item, for single inspection.
name_task: what we used in code. name_plot: what we want to show in the plot.
For now, take the max over the iterations (easy to spot check w/curves).
Actually we have two cases to watch out for (goal conditioned or not)

For the table, I'm going to add a few more commands to make it a little easier to copy/paste.
Use this for printing a SINGLE item for single inspection . name_task : what we used in code . name_plot : what we want to show in the plot . For now take the max over the iterations ( easy to spot check w / curves ) . Actually we have two cases to watch out for ( goal conditioned or not ) For the table I ' m going to add a few more commands to make it a little easier to copy / paste .
def print_single(args, goal_conditioned, name_task, name_plot):
    def get_max(stats_combo, ag_key):
        stat_max = -1
        for key in sorted(stats_combo[ag_key].keys()):
            stat_max = max(stat_max, np.mean(stats_combo[ag_key][key]))
        stat_max *= 100  
        return stat_max
    a1, a2, a3, a4, a5, a6, a7 = {}, {}, {}, {}, {}, {}, {}
    for num_demos in [1, 10, 100, 1000]:
        directories, seeds = get_subdirectories_demos(name_task, num_demos)
        stats_combo = _get_results(name_task, directories, seeds, debug)
        agents = sorted(stats_combo.keys())
        print(f'For task {name_task}, we have results from agents: {agents}')
        if '-transporter' in agents:
            a1[num_demos] = get_max(stats_combo, ag_key='-transporter')
        if '-transporter-goal' in agents:
            a2[num_demos] = get_max(stats_combo, ag_key='-transporter-goal')
        if '-transporter-goal-naive' in agents:
            a3[num_demos] = get_max(stats_combo, ag_key='-transporter-goal-naive')
        if '-gt_state' in agents:
            a4[num_demos] = get_max(stats_combo, ag_key='-gt_state')
        if '-gt_state_2_step' in agents:
            a5[num_demos] = get_max(stats_combo, ag_key='-gt_state_2_step')
        if '-conv_mlp' in agents:
            a6[num_demos] = get_max(stats_combo, ag_key='-gt_state_2_step')
        if '-transporter-goal-snaive' in agents:
            a7[num_demos] = get_max(stats_combo, ag_key='-transporter-goal-snaive')
    print('\nDebugging of which results we have:')
    print(f'keys in a1 (transporter):              {sorted(a1.keys())}')
    print(f'keys in a2 (transporter-goal-split):   {sorted(a2.keys())}')
    print(f'keys in a3 (transporter-goal-naive):   {sorted(a3.keys())} [note should not use this]')
    print(f'keys in a4 (gt_state):                 {sorted(a4.keys())}')
    print(f'keys in a5 (gt_state_2_step):          {sorted(a5.keys())}')
    print(f'keys in a6 (conv_mlp):                 {sorted(a6.keys())}')
    print(f'keys in a7 (transporter-goal-stack): {sorted(a7.keys())}')
    N = ''
    s = '\n  \\begin{tabular}{@{}lrrrr}'
    s += '\n  \\toprule'
    s += f'\n  & \multicolumn{{4}}{{c}}{{{name_plot}}} \\\\'
    s += '\n  \cmidrule(lr){2-5}'
    s += '\n  Method & 1 & 10 & 100 & 1000 \\\\'
    s += '\n  \midrule'
    s += (f'\n  GT-State MLP            & {a4[1]:0.1f} & {a4[10]:0.1f} & {a4[100]:0.1f} & {a4[1000]:0.1f} \\\\')
    s += (f'\n  GT-State MLP 2-Step     & {a5[1]:0.1f} & {a5[10]:0.1f} & {a5[100]:0.1f} & {a5[1000]:0.1f} \\\\')
    if goal_conditioned:
        s += (f'\n  Transporter-Goal-Stack  & {a7[1]:0.1f} & {a7[10]:0.1f} & {a7[100]:0.1f} & {a7[1000]:0.1f} \\\\')  
        s += (f'\n  Transporter-Goal-Split  & {a2[1]:0.1f} & {a2[10]:0.1f} & {a2[100]:0.1f} & {a2[1000]:0.1f} \\\\')
    else:
        s += (f'\n  Transporter             & {a1[1]:0.1f} & {a1[10]:0.1f} & {a1[100]:0.1f} & {a1[1000]:0.1f} \\\\')
    s += '\n  \\toprule'
    s += '\n  \\end{tabular}'
    print(s)
def print_single ( args , goal_conditioned , name_task , name_plot ) : def get_max ( stats_combo , ag_key ) : stat_max = - 1 for key in sorted ( stats_combo [ ag_key ] . keys ( ) ) : stat_max = max ( stat_max , np . mean ( stats_combo [ ag_key ] [ key ] ) ) stat_max *= 100 return stat_max a1 , a2 , a3 , a4 , a5 , a6 , a7 = { } , { } , { } , { } , { } , { } , { } for num_demos in [ 1 , 10 , 100 , 1000 ] : directories , seeds = get_subdirectories_demos ( name_task , num_demos ) stats_combo = _get_results ( name_task , directories , seeds , debug ) agents = sorted ( stats_combo . keys ( ) ) print ( f'For task {name_task}, we have results from agents: {agents}' ) if '-transporter' in agents : a1 [ num_demos ] = get_max ( stats_combo , ag_key = '-transporter' ) if '-transporter-goal' in agents : a2 [ num_demos ] = get_max ( stats_combo , ag_key = '-transporter-goal' ) if '-transporter-goal-naive' in agents : a3 [ num_demos ] = get_max ( stats_combo , ag_key = '-transporter-goal-naive' ) if '-gt_state' in agents : a4 [ num_demos ] = get_max ( stats_combo , ag_key = '-gt_state' ) if '-gt_state_2_step' in agents : a5 [ num_demos ] = get_max ( stats_combo , ag_key = '-gt_state_2_step' ) if '-conv_mlp' in agents : a6 [ num_demos ] = get_max ( stats_combo , ag_key = '-gt_state_2_step' ) if '-transporter-goal-snaive' in agents : a7 [ num_demos ] = get_max ( stats_combo , ag_key = '-transporter-goal-snaive' ) print ( '\nDebugging of which results we have:' ) print ( f'keys in a1 (transporter):              {sorted(a1.keys())}' ) print ( f'keys in a2 (transporter-goal-split):   {sorted(a2.keys())}' ) print ( f'keys in a3 (transporter-goal-naive):   {sorted(a3.keys())} [note should not use this]' ) print ( f'keys in a4 (gt_state):                 {sorted(a4.keys())}' ) print ( f'keys in a5 (gt_state_2_step):          {sorted(a5.keys())}' ) print ( f'keys in a6 (conv_mlp):                 {sorted(a6.keys())}' ) print ( f'keys in a7 (transporter-goal-stack): {sorted(a7.keys())}' ) N = '' s = '\n  \\begin{tabular}{@{}lrrrr}' s += '\n  \\toprule' s += f'\n  & \multicolumn{{4}}{{c}}{{{name_plot}}} \\\\' s += '\n  \cmidrule(lr){2-5}' s += '\n  Method & 1 & 10 & 100 & 1000 \\\\' s += '\n  \midrule' s += ( f'\n  GT-State MLP            & {a4[1]:0.1f} & {a4[10]:0.1f} & {a4[100]:0.1f} & {a4[1000]:0.1f} \\\\' ) s += ( f'\n  GT-State MLP 2-Step     & {a5[1]:0.1f} & {a5[10]:0.1f} & {a5[100]:0.1f} & {a5[1000]:0.1f} \\\\' ) if goal_conditioned : s += ( f'\n  Transporter-Goal-Stack  & {a7[1]:0.1f} & {a7[10]:0.1f} & {a7[100]:0.1f} & {a7[1000]:0.1f} \\\\' ) s += ( f'\n  Transporter-Goal-Split  & {a2[1]:0.1f} & {a2[10]:0.1f} & {a2[100]:0.1f} & {a2[1000]:0.1f} \\\\' ) else : s += ( f'\n  Transporter             & {a1[1]:0.1f} & {a1[10]:0.1f} & {a1[100]:0.1f} & {a1[1000]:0.1f} \\\\' ) s += '\n  \\toprule' s += '\n  \\end{tabular}' print ( s )
Use this for printing a SINGLE item, for single inspection.
Use this for printing a SINGLE item for single inspection .
"""Use this for printing a SINGLE item, for single inspection.

    name_task: what we used in code. name_plot: what we want to show in the plot.
    For now, take the max over the iterations (easy to spot check w/curves).
    Actually we have two cases to watch out for (goal conditioned or not)...

    For the table, I'm going to add a few more commands to make it a little easier to copy/paste.
    """ # We want this in %, in [0,100] # Map from num_demos ---> statistic. Note: DIFFERENT from earlier where we had lists. # To be honest this is more scalable as we don't need to wait for all demos to finish. # Earlier we appended w/demos, and caused issues if we were missing early demo counts. # Get relevant directories for each demo, then relevant stats. # Manually replace keys with N if we don't have it (I know, I know ...) # Use a1 through a5 default dicts. Keys are NUM DEMOS, not tasks. # should be a7
args
goal_conditioned
name_task
name_plot