parser.add_argument('-o', '--output', dest='output', required=False, action='store', default=None, help='Output directory.') opts = parser.parse_args() if opts.output == None: outdir = tempfile.mkdtemp(dir=os.curdir, prefix='out') logger.info('Output directory %s', outdir) else: outdir = opts.output if not os.path.exists(outdir): tsh.makedirs(outdir) config = tsh.read_config(opts, __file__) basename = os.path.splitext(os.path.basename(opts.model))[0] propagator = read_propagatorfile(opts.model) cv_results = propagator['meta']['cv_results'] data = {} for score, params, cm in cv_results: key = tuple(params.items()) if key not in data: data[key] = [] data[key] += [score] all_param_keys = sorted(data.keys()) data = tsh.dict_values(data, all_param_keys) plt.errorbar(range(len(all_param_keys)), np.mean(data, axis=1), fmt='ro', yerr=np.std(data, axis=1))
parser = argparse.ArgumentParser(description='Computes features for all the input data.') parser.add_argument('-c', '--config', dest='config', required=False, action='store', default=None, help='Path to the config file') parser.add_argument('-m', '--method', dest='method', required=True, action='store', choices=method_table.keys(), default=None, help='Method name.') parser.add_argument('-a', '--args', dest='args', required=False, action='store', default=None, help='Method arguments file.') parser.add_argument('-l', '--list', dest='list', required=True, action='store', default=None, help='List file.') parser.add_argument('-j', '--jobs', dest='jobs', required=False, action='store', default=None, type=int, help='Number of parallel processes.') parser.add_argument('-o', '--output', dest='output', required=False, action='store', default=None, help='Output directory.') opts = parser.parse_args() if opts.output == None: outdir = tempfile.mkdtemp(dir=os.curdir, prefix='out') logger.info('Output directory %s', outdir) else: outdir = opts.output if not os.path.exists(outdir): tsh.makedirs(outdir) inputname = os.path.splitext(os.path.basename(opts.list))[0] if opts.list.endswith('.gz'): inputname = os.path.splitext(inputname)[0] outputname = os.path.join(outdir, inputname + '-feats.csv.gz') if os.path.exists(outputname): logger.info('Skipping file %s, already exists.', outputname) else: config = tsh.read_config(opts, __file__) meta, data = read_listfile(opts.list) args = meta if opts.args != None: args.update(read_argsfile(opts.args)) args, features = compute_features(opts.method, args, data, input_name=inputname, n_jobs=opts.jobs, output_dir=outdir) clean_args(args) write_listfile(outputname, features, input_name=inputname, **args)