Exemplo n.º 1
0
        '--nsamples',
        type=int,
        default=1024,
        help='Number of posterior samples to average (only used for DTSRBayes)'
    )
    argparser.add_argument(
        '-M',
        '--mode',
        type=str,
        default=None,
        help=
        'Predict mode ("response" or "loglik") or default None, which does both'
    )
    args, unknown = argparser.parse_known_args()

    p = Config(args.config_path)
    if len(args.models) > 0:
        models = args.models
    else:
        models = p.model_list[:]

    run_baseline = False
    run_dtsr = False
    for m in models:
        if not run_baseline and m.startswith('LM') or m.startswith('GAM'):
            run_baseline = True
        elif not run_dtsr and m.startswith('DTSR'):
            run_dtsr = True

    dtsr_formula_list = [
        Formula(p.models[m]['formula']) for m in p.model_list
Exemplo n.º 2
0

    table_str += '\\end{tabular}\n\\end{table}'
    print(table_str)

if __name__ == '__main__':

    argparser = argparse.ArgumentParser('''
    Generates a LaTeX table of beta summaries for one or more DTSR models
    ''')
    argparser.add_argument('config', help='Path to config file defining models')
    argparser.add_argument('-m', '--models', nargs='+', default=[], help='Folder name(s) containing model eval summaries (if blank applies to all models described in config file).')
    argparser.add_argument('-n', '--names', nargs='*', default=[], help='Model names to print in table (must be omitted or same length as --models).')
    args = argparser.parse_args()

    p = Config(args.config)
    if len(args.models) == 0:
        models = p.model_list[:]
    else:
        models = args.models[:]

    if len(args.names) == 0:
        names = p.model_list[:]
    else:
        assert len(args.names) == len(models), 'Length mismatch between number of models and number of model names'
        names = args.names

    beta_summaries = {}
    beta_names = set()

    for i in range(len(models)):
Exemplo n.º 3
0
    argparser = argparse.ArgumentParser('''
    Generates plots of fitted spillover estimates for "fullS" baseline models, visualizing those models' estimates of temporal diffusion.
    ''')
    argparser.add_argument('paths', nargs='+', help='Paths to config files defining baseline models to plot')
    argparser.add_argument('-m', '--models', nargs='*', default=None, help='List of models to plot. If none specified, plots all relevant models in the config files')
    argparser.add_argument('-x', '--x', type=float, default=6, help='Width of plots in inches')
    argparser.add_argument('-X', '--xlab', type=str, default=None, help='x-axis label (if default -- None -- no label)')
    argparser.add_argument('-y', '--y', type=float, default=4, help='Height of plots in inches')
    argparser.add_argument('-Y', '--ylab', type=str, default=None, help='y-axis label (if default -- None -- no label)')
    argparser.add_argument('-c', '--cmap', type=str, default='gist_rainbow', help='Name of matplotlib colormap library to use for curves')
    argparser.add_argument('-l', '--nolegend', action='store_true', help='Omit legend from figure')
    args = argparser.parse_args()

    configs = []
    for c in args.paths:
        configs.append(Config(c))

    if args.models is None:
        models = []
    else:
        models = [x for x in args.models if ('LMfullS' in x or 'LMEfullS' in x)]
        assert len(models > 0), 'No valid models in script call. Models must be linear fullS models.'

    cm = plt.get_cmap(args.cmap)
    legend = not args.nolegend

    for p in configs:
        if len(models) == 0:
            models = [x for x in p.model_list[:] if ('LMfullS' in x or 'LMEfullS' in x)]
        for name in models:
            dirpath = p.logdir + '/' + name + '/'
Exemplo n.º 4
0
Arquivo: plot.py Projeto: vansky/dtsr
        type=str,
        default='gist_rainbow',
        help='Name of matplotlib colormap library to use for curves')
    argparser.add_argument('-l',
                           '--nolegend',
                           action='store_true',
                           help='Omit legend from figure')
    argparser.add_argument(
        '-t',
        '--transparent_background',
        action='store_true',
        help='Use transparent background (otherwise white background)')
    args, unknown = argparser.parse_known_args()

    for path in args.paths:
        p = Config(path)

        if not p.use_gpu_if_available:
            os.environ['CUDA_VISIBLE_DEVICES'] = '-1'

        if len(args.models) > 0:
            models = [
                m for m in args.models
                if (m in p.model_list and m.startswith('DTSR'))
            ]
        else:
            models = p.model_list[:]
        prefix = args.prefix
        if prefix != '':
            prefix += '_'
        n_time_units = args.ntimeunits
Exemplo n.º 5
0
                           default=[],
                           help='List of paths to config files.')
    argparser.add_argument(
        '-p',
        '--partition',
        type=str,
        default='dev',
        help='Name of partition to use (one of "train", "dev", "test")')
    args, unknown = argparser.parse_known_args()

    losses = {}
    select = {}

    systems = set()
    for task in args.tasks:
        p = Config(task)
        models = p.model_list[:]
        systems = systems.union(
            set([model2name(x.split('_')[0].strip()) for x in models]))
        for m in models:
            if os.path.exists(p.outdir + '/' + m + '/%s_losses_%s.txt' %
                              (p.loss, args.partition)):
                sys_name, trial_name = m.split('_')
                sys_name = model2name(sys_name)
                if sys_name.startswith('LME') and trial_name == 'noRE':
                    l = pd.read_csv(p.outdir + '/' + m + '/%s_losses_%s.txt' %
                                    (p.loss, args.partition),
                                    sep=' ',
                                    header=None,
                                    skipinitialspace=True)
                else: