Exemplo n.º 1
0
def get_optparser():

    dataset_options = ''
    for k in sorted(datasets.keys()):
      dataset_options +=  ("     %s - %s \n" % (k, datasets[k].__name__))

    usage = ("usage: %prog <DATASET> <DATASET_PATH>\n\n"
             "DATASET is an integer corresponding to the following supported "
             "datasets:\n" + dataset_options
            )

    parser = optparse.OptionParser(usage=usage)

    hp_algo_default = hp_algos['default']
    hp_algos.pop('default', None)
    hp_algo_opts = ' OPTIONS=%s' % (hp_algos.keys())

    learn_algo_default = learning_algos['default']
    learning_algos.pop('default', None)
    learn_algo_opts = ' OPTIONS=%s' % (learning_algos.keys())

    opt_modes_str = ' OPTIONS=%s' % (opt_modes)

    parser.add_option("--opt_mode", "-M",
                      default=opt_modes[0],
                      type="str",
                      metavar="STR",
                      help="[DEFAULT='%default']" + opt_modes_str)

    parser.add_option("--output_path", "-O",
                      default=None,
                      type="str",
                      metavar="STR",
                      help=("Required when opt_mode='serial' "
                            "[DEFAULT='%default']"))

    parser.add_option("--hp_space", "-S",
                      default='default',
                      type="str",
                      metavar="STR",
                      help="[DEFAULT='%default']")

    parser.add_option("--hyperopt_algo", "-H",
                      default=hp_algo_default,
                      type="str",
                      metavar="STR",
                      help="[DEFAULT='%default']" + hp_algo_opts)

    parser.add_option("--learning_algo", "-A",
                      default=learn_algo_default,
                      type="str",
                      metavar="STR",
                      help="[DEFAULT='%default']" + learn_algo_opts)

    parser.add_option("--n_startup_trials", "-T",
                      default=n_startup_trials,
                      type="int",
                      metavar="INT",
                      help="[DEFAULT='%default']")

    parser.add_option("--n_ok_trials", "-N",
                      default=n_ok_trials,
                      type="int",
                      metavar="INT",
                      help="[DEFAULT='%default']")

    parser.add_option("--host", "-W",
                      default='localhost',
                      type="str",
                      metavar="STR",
                      help=("Only considered when optimization mode='async' "
                            "[DEFAULT='%default']"))

    parser.add_option("--port", "-P",
                      default=10921,
                      type="int",
                      metavar="INT",
                      help=("Only considered when optimization mode='async' "
                            "[DEFAULT='%default']"))

    return parser
Exemplo n.º 2
0
def get_optparser():

    dataset_options = ''
    for k in sorted(datasets.keys()):
      dataset_options +=  ("     %s - %s \n" % (k, datasets[k].__name__))

    usage = ("usage: %prog <DATASET> <DATASET_PATH>\n\n"
             "+ DATASET is an integer corresponding to the following supported "
             "datasets:\n" + dataset_options + '\n'
             "+ HP_FNAME is the pkl file containing the result of a previous "
             "hyperparameter optimization."
            )

    parser = optparse.OptionParser(usage=usage)

    learn_algo_default = learning_algos['default']
    learning_algos.pop('default', None)
    learn_algo_opts = ' OPTIONS=%s' % (learning_algos.keys())

    parser.add_option("--hp_fname", "-F",
                      default=None,
                      type="str",
                      metavar="STR",
                      help=("Pickle file created by optimization in serial"
                            "mode. [DEFAULT='%default']"
                            )
                        )

    parser.add_option("--host", "-H",
                      default=None,
                      type="str",
                      metavar="STR",
                      help=("Host serving MongoDB database created by "
                            "optimization running in asynchronous, parallel "
                            "mode. [DEFAULT='%default']"
                            )
                        )

    parser.add_option("--port", "-P",
                      default=10921,
                      type="int",
                      metavar="INT",
                      help=("MongoDB port at host serving the database. "
                            "[DEFAULT='%default']"
                            )
                        )

    parser.add_option("--learning_algo", "-A",
                      default=learn_algo_default,
                      type="str",
                      metavar="STR",
                      help="[DEFAULT='%default']" + learn_algo_opts)

    parser.add_option("--int_samples", "-S",
                      default=False,
                      action="store_true",
                      help="output interesting misses and hits in current " \
                           "path [DEFAULT='%default']")


    return parser