Lileb-Training/src/utils/plotting.py
def plot_aucs(all_aucs, task_viz, main_viz):
    """
    Update the auc curves:
        - Draw k vs auc@k in the environment of this training for the current
        task
        - Draw k vs average auc@k on all tasks seen by this model so far (in
        the training and global envs).
    :param all_aucs: List containing the auc of a given model for all tasks.
    Each element of this list is in the format
    returned by `get_aucs`: {'split_1' :([x1, x2, ...], [auc@x1, auc@x2, ...]),
                             'split_2' :([x1, x2, ...], [auc@x1, auc@x2, ...]),
                             ...}
    :param task_viz: The Visdom environment of the concerned training (model
    and task).
    :param main_viz: The Visdom environment of the global experiment.
    :return:
    """
    ### Update AUC plots
    opts = {'legend': list(all_aucs[-1].keys()), 'markersize': 3,
            'xlabel': 'n iterations', 'ylabel': 'AuC'}

    # Current task
    all_points, labels = [], []
    last_auc = all_aucs[-1]
    for i, (split, (x, y)) in enumerate(last_auc.items()):
        all_points.extend(zip(x, y))
        labels.extend([i + 1] * len(x))
    task_viz.scatter(all_points, labels, win='task_auc',
                     opts={'title': 'Task AUCs', **opts})

    # All tasks so far
    split_aucs = defaultdict(list)
    for t_aucs in all_aucs:
        for split, (x, y) in t_aucs.items():
            assert x == all_aucs[0][split][
                0], 'All AUC of a split should be computed at the same points'
            split_aucs[split].append(y)

    ys = np.mean(list(split_aucs.values()), 1).reshape(-1)
    xs = all_aucs[0]['Train'][0]
    labels = np.repeat(range(len(split_aucs)), len(xs)) + 1
    xs = np.tile(xs, len(split_aucs))

    task_viz.scatter(np.array([xs, ys]).transpose(), labels, opts={
        'title': 'Average task AUCs {}'.format(len(all_aucs)),
        **opts})
    main_viz.scatter(np.array([xs, ys]).transpose(), labels, win='task_aucs',
                     opts={'title': 'Task AUCs {}'.format(len(all_aucs)),
                           **opts})

    Update the auc curves:
        - Draw k vs auc@k in the environment of this training for the current
        task
        - Draw k vs average auc@k on all tasks seen by this model so far (in
        the training and global envs).
    :param all_aucs: List containing the auc of a given model for all tasks.
    Each element of this list is in the format
    returned by `get_aucs`: {'split_1' :([x1, x2, ...], [auc@x1, auc@x2, ...]),
                             'split_2' :([x1, x2, ...], [auc@x1, auc@x2, ...]),
                             ...}
    :param task_viz: The Visdom environment of the concerned training (model
    and task).
    :param main_viz: The Visdom environment of the global experiment.
    :return:
    
Update the auc curves:
Draw k vs auc@k in the environment of this training for the current
task
Draw k vs average auc@k on all tasks seen by this model so far (in
the training and global envs).
Update the auc curves : Draw k vs auc@k in the environment of this training for the current task Draw k vs average auc@k on all tasks seen by this model so far ( in the training and global envs ) .
def plot_aucs(all_aucs, task_viz, main_viz):
    opts = {'legend': list(all_aucs[-1].keys()), 'markersize': 3,
            'xlabel': 'n iterations', 'ylabel': 'AuC'}
    all_points, labels = [], []
    last_auc = all_aucs[-1]
    for i, (split, (x, y)) in enumerate(last_auc.items()):
        all_points.extend(zip(x, y))
        labels.extend([i + 1] * len(x))
    task_viz.scatter(all_points, labels, win='task_auc',
                     opts={'title': 'Task AUCs', **opts})
    split_aucs = defaultdict(list)
    for t_aucs in all_aucs:
        for split, (x, y) in t_aucs.items():
            assert x == all_aucs[0][split][
                0], 'All AUC of a split should be computed at the same points'
            split_aucs[split].append(y)
    ys = np.mean(list(split_aucs.values()), 1).reshape(-1)
    xs = all_aucs[0]['Train'][0]
    labels = np.repeat(range(len(split_aucs)), len(xs)) + 1
    xs = np.tile(xs, len(split_aucs))
    task_viz.scatter(np.array([xs, ys]).transpose(), labels, opts={
        'title': 'Average task AUCs {}'.format(len(all_aucs)),
        **opts})
    main_viz.scatter(np.array([xs, ys]).transpose(), labels, win='task_aucs',
                     opts={'title': 'Task AUCs {}'.format(len(all_aucs)),
                           **opts})
def plot_aucs ( all_aucs , task_viz , main_viz ) : opts = { 'legend' : list ( all_aucs [ - 1 ] . keys ( ) ) , 'markersize' : 3 , 'xlabel' : 'n iterations' , 'ylabel' : 'AuC' } all_points , labels = [ ] , [ ] last_auc = all_aucs [ - 1 ] for i , ( split , ( x , y ) ) in enumerate ( last_auc . items ( ) ) : all_points . extend ( zip ( x , y ) ) labels . extend ( [ i + 1 ] * len ( x ) ) task_viz . scatter ( all_points , labels , win = 'task_auc' , opts = { 'title' : 'Task AUCs' , ** opts } ) split_aucs = defaultdict ( list ) for t_aucs in all_aucs : for split , ( x , y ) in t_aucs . items ( ) : assert x == all_aucs [ 0 ] [ split ] [ 0 ] , 'All AUC of a split should be computed at the same points' split_aucs [ split ] . append ( y ) ys = np . mean ( list ( split_aucs . values ( ) ) , 1 ) . reshape ( - 1 ) xs = all_aucs [ 0 ] [ 'Train' ] [ 0 ] labels = np . repeat ( range ( len ( split_aucs ) ) , len ( xs ) ) + 1 xs = np . tile ( xs , len ( split_aucs ) ) task_viz . scatter ( np . array ( [ xs , ys ] ) . transpose ( ) , labels , opts = { 'title' : 'Average task AUCs {}' . format ( len ( all_aucs ) ) , ** opts } ) main_viz . scatter ( np . array ( [ xs , ys ] ) . transpose ( ) , labels , win = 'task_aucs' , opts = { 'title' : 'Task AUCs {}' . format ( len ( all_aucs ) ) , ** opts } )
Update the auc curves:
 Draw k vs auc@k in the environment of this training for the current
task
 Draw k vs average auc@k on all tasks seen by this model so far (in
the training and global envs).
Update the auc curves : Draw k vs auc@k in the environment of this training for the current task Draw k vs average auc@k on all tasks seen by this model so far ( in the training and global envs ) .
"""
    Update the auc curves:
        - Draw k vs auc@k in the environment of this training for the current
        task
        - Draw k vs average auc@k on all tasks seen by this model so far (in
        the training and global envs).
    :param all_aucs: List containing the auc of a given model for all tasks.
    Each element of this list is in the format
    returned by `get_aucs`: {'split_1' :([x1, x2, ...], [auc@x1, auc@x2, ...]),
                             'split_2' :([x1, x2, ...], [auc@x1, auc@x2, ...]),
                             ...}
    :param task_viz: The Visdom environment of the concerned training (model
    and task).
    :param main_viz: The Visdom environment of the global experiment.
    :return:
    """ ### Update AUC plots # Current task # All tasks so far
None
all_aucs
List containing the auc of a given model for all tasks.
List containing the auc of a given model for all tasks .
task_viz
The Visdom environment of the concerned training (model
and task).
The Visdom environment of the concerned training ( model and task ) .
main_viz
The Visdom environment of the global experiment.
The Visdom environment of the global experiment .