예제 #1
0
def handle_options():
    """Handle command line and config file options."""
    o = OptionParser()
    c = ConfigParser()
    c.add_optparse_help_option(o)
    c.add_optparse_files_option(o)
    c.add_file('default.cfg')
    o.add_option("-v","--verbose", action="store_true", dest="verbose",
            help="Be verbose.",default=False)
    o.add_option("--debug", action="store_true", dest="debug",
            help="Print extra debugging info to STDOUT", default=False)
    o.add_option("--quiet", action="store_true", dest="quiet",
            help="Only print the bare minimum information.",default=False)
    o.add_option("--noplot", action="store_true", dest="no_plot",
            help="Disable creation of plots entirely.", default=False)
    o.add_option("--nostats", action="store_true", dest="no_stats",
            help="Do not compute any statistics for the result.", default=False)
    o.add_option("-i", "--identifier", type="string",
            help="Unique identifier for this run.", metavar="ID")
    c.add_option("identifier")
    o.add_option("--suffix", type="string",default="",
            help="Suffix to add to the identifier")
    o.add_option("-f", "--filename", type="string",
            help="File name of the data file", metavar="FILE")
    c.add_option("filename")
    o.add_option("--data-dir", type="string",dest="data_dir",
            help="Directory containing the data files. This will be"+
                 " concatenated with filename to yield the comple path.", metavar="DIR")
    c.add_option("data_dir",dest="data_dir")
    o.add_option("--output", type="string", dest="output_dir",
            help="Directory for the output files (default: output)", metavar="DIR")
    c.add_option("output_dir",dest="output_dir",default="output")
    o.add_option("-d","--dims",dest="use_dims",type="int",
            help="Number of dimensions to use. If 0, all data dimensions will"+
            " be used.")
    c.add_option("dims",dest="use_dims",default=0)
    o.add_option("--rows",dest="use_rows",type="int",
            help="Number of rows of data to be used. If 0, all are used.")
    c.add_option("rows",dest="use_rows",default=0)
    o.add_option("-p","--use-particle",dest="use_particle",type="int",
                 default=0,help="Particle ID for labeling",metavar="ID")
    o.add_option("--merge-noise",dest="merge_noise",type="float",default=0.,
            help="Merge all clusters with NUM% of the data into one.",
            metavar="NUM")
    o.add_option("--subsample",type="int",default=0,metavar="NUM",
            help="Subsample data set to contain this number of points (0: all).")
    o.add_option("--binary-label",action="store_true",default=False,
            dest="binary_label",help="The label is binary: compare only the " +
            "cluster with the largest overlap to the one with label 1.")
    o.add_option("--true-labels",action="store_true",default=False,
            dest="true_labels",help="Use the true labels for plotting. ")
    o.add_option("--plot-fmt",type="choice",choices=("eps","pdf","png","jpg"),
            dest="output_format",
            default="eps",help="Plot output format (eps,pdf,png,jpg).")
    o.add_option("--label-file",type="string",dest="label_file",default="",
            help="File containing the labels.")

    (options,args) = c.parse(o)
    options.identifier = options.identifier + options.suffix
    return (options,args)
예제 #2
0
def handle_options():
    """Handle command line and config file options."""
    o = OptionParser()
    c = ConfigParser()
    c.add_optparse_help_option(o)
    c.add_optparse_files_option(o)
    f = c.add_file('cfgs/default.cfg')
    o.add_option("-v","--verbose", action="store_true", dest="verbose",
            help="Be verbose.",default=False)
    o.add_option("--debug", action="store_true", dest="debug",
            help="Print extra debugging info to STDOUT", default=False)
    o.add_option("-i", "--identifier", type="string",
            help="Unique identifier for this run.", metavar="ID")
    c.add_option("identifier")
    o.add_option("--suffix", type="string",default="",
            help="Suffix to add to the identifier")
    o.add_option("-f", "--filename", type="string",
            help="File name of the data file", metavar="FILE")
    c.add_option("filename")
    o.add_option("--data-dir", type="string",dest="data_dir",
            help="Directory containing the data files. This will be"+
                 " concatenated with filename to yield the comple path.", metavar="DIR")
    c.add_option("data_dir",dest="data_dir")
    o.add_option("--output", type="string", dest="output_dir",
            help="Directory for the output files (default: output)", metavar="DIR")
    c.add_option("output_dir",dest="output_dir",default="output")
    o.add_option("--force",action="store_true",dest="overwrite",default=False,
            help="Run even if the output directory already exists.")
    o.add_option("-n","--particles", type="int",
            help="Number of particles to use", 
            metavar="NUM")
    c.add_option('particles')
    o.add_option("--max-clusters", type="int", dest="max_clusters",
            help="Maximum possible number of clusters.", 
            metavar="NUM")
    c.add_option('max_clusters',dest="max_clusters",default=100)

    o.add_option("-a","--algorithm",dest="algorithm",type="choice",
            metavar="ALG",choices=("pf","gibbs","mh","compute-joint"),
            help="Inference algorithm to use (pf,gibbs,mh).")
    c.add_option('algorithm')
    o.add_option("-d","--dims",dest="use_dims",type="int",
            help="Number of dimensions to use. If 0, all data dimensions will"+
            " be used.")
    c.add_option("dims",dest="use_dims",default=0)
    o.add_option("--rows",dest="use_rows",type="int",
            help="Number of rows of data to be used. If 0, all are used.")
    c.add_option("rows",dest="use_rows",default=0)
    o.add_option("--save-particle",dest="save_particle",type="choice",
            metavar="NUM",choices=("none","one","all"),
            help="Number of particles to save (none,one,all)")
    c.add_option('save_particle',dest="save_particle",default="none")
    o.add_option("--draw-prior", action="store_true", dest="draw_prior",
            help="Make a plot of draws from the prior and exit.", default=False)

    ### Model options
    c.add_option('a',check=parse_array_string,
            help="Alpha parameter of the Gamma prior")
    c.add_option('b',check=parse_array_string,
            help="Beta parameter of the Gamma prior")
    c.add_option('mu0',check=parse_array_string,
            help="mu0 parameter of the prior")
    c.add_option('n0',check=parse_array_string,
            help="n0 parameter of the prior")

    c.add_option("kernel_class",type="choice",
            choices=("caron","metropolis"), check=get_kernel_class,
            help="Transition kernel; either 'caron' or 'metropolis'")
    o.add_option("--aux-vars",type="int",dest="aux_vars",
            help="Number of auxiliary variables to use in the Caron kernel.")
    c.add_option("aux_vars",dest="aux_vars")
    c.add_option("variance_factor",type="float",
            help="Variance scaling factor to use in the Caron kernel.")
    c.add_option("mean_sd",type="float",
            help="Standard deviation of the proposal for the mean in the" +
                 " Metropolis kernel.")
    c.add_option("precision_sd",type="float",
            help="Standard deviation of the proposal for the precision in the" +
                 " Metropolis kernel.")

    ### Other model options
    o.add_option("--alpha",type="float",
            help="The DP concentration parameter alpha.")
    c.add_option("alpha")
    o.add_option("--rho",type="float",
            help="Probability of survival of an allocation variable")
    c.add_option("rho")
    c.add_option("p_uniform_deletion",type="float",
            help="Probability of uniform deletion.")
    o.add_option("--rp",type="float",
            help="Length of the absolute refractory period (in ms)")
    c.add_option("rp")
   
    ### Particle Filter Options
    c.add_option("storage_class",type="choice",check=get_storage_class,
            choices=("dynamic","fixed","ring"),
            help="Storage container to use; one of ('dynamic','fixed','ring')")
    c.add_option("resampling_method", type="choice",
            check=get_resampling_function,
            choices=("multinomial","residual","stratified","systematic"),
            help="Resampling scheme; one of (multinomial,residual,stratified,"+
                 "systematic)")


    (options,args) = c.parse(o)
    options.identifier += options.suffix
    set_kernel_parameters(options)
    return (options,args)