コード例 #1
0
def main():
    """
    This is used as the entry point for fitting.
    """

    parser = argparse.ArgumentParser()
    parser.add_argument("--database-analysis",
                        "-d",
                        dest="database_analysis",
                        help="analysis database to be used",
                        required=True)
    parser.add_argument("--analysis",
                        "-a",
                        dest="type_ana",
                        help="choose type of analysis",
                        required=True)
    parser.add_argument("--period-number", "-p", dest="period_number", type=int,
                        help="choose type of analysis (0: 2016, 1: 2017, 2: 2018, " \
                             "-1: all merged (default))", default=-1)
    parser.add_argument("--output",
                        "-o",
                        default="simple_fit",
                        help="result output directory")

    args = parser.parse_args()

    configure_logger(False, None)

    # Extract database as dictionary
    data = parse_yaml(args.database_analysis)
    data = data[list(data.keys())[0]]
    # Run the chain
    do_simple_fit(data, args.type_ana, args.period_number, args.output)
コード例 #2
0
def main():
    """
    This is used as the entry point for ml-analysis.
    Read optional command line arguments and launch the analysis.
    """

    parser = argparse.ArgumentParser()
    parser.add_argument("--debug",
                        action="store_true",
                        help="activate debug log level")
    parser.add_argument("--log-file",
                        dest="log_file",
                        help="file to print the log to")
    parser.add_argument("--run-config",
                        "-r",
                        dest="run_config",
                        help="the run configuration to be used")
    parser.add_argument("--database-analysis",
                        "-d",
                        dest="database_analysis",
                        help="analysis database to be used")
    parser.add_argument("--database-ml-models",
                        dest="database_ml_models",
                        help="ml model database to be used")
    parser.add_argument("--database-run-list",
                        dest="database_run_list",
                        help="run list database to be used")
    parser.add_argument("--analysis",
                        "-a",
                        dest="type_ana",
                        help="choose type of analysis")

    args = parser.parse_args()

    configure_logger(args.debug, args.log_file)

    # Extract which database and run config to be used
    pkg_data = "machine_learning_hep.data"
    pkg_data_run_config = "machine_learning_hep.submission"
    run_config = load_config(args.run_config,
                             (pkg_data_run_config, "default_complete.yml"))
    case = run_config["case"]
    if args.type_ana is not None:
        run_config["analysis"]["type"] = args.type_ana

    db_analysis_default_name = f"database_ml_parameters_{case}.yml"
    print(args.database_analysis)
    db_analysis = load_config(args.database_analysis,
                              (pkg_data, db_analysis_default_name))
    db_ml_models = load_config(args.database_ml_models,
                               (pkg_data, "config_model_parameters.yml"))
    db_run_list = load_config(args.database_run_list,
                              (pkg_data, "database_run_list.yml"))

    # Run the chain
    do_entire_analysis(run_config, db_analysis, db_ml_models, db_run_list)
コード例 #3
0
def main():
    """
    Parse and handle arguments and dispatch to central function doclassification_regression.
    This includes following steps:
        1) Configure the logger
        2) Dump default configuration YAMLs if requested (exit afterwards assuming the user wants
                                                         to edit and use them later)
        3) Steer doclassification_regression with extracted configuration
    """
    parser = argparse.ArgumentParser()
    # Require a config file with some plotting info
    parser.add_argument("--dump-default-config",
                        dest="dump_default_config",
                        help="get default run parameters as YAML config file")
    parser.add_argument(
        "--dump-default-models",
        dest="dump_default_models",
        help="get default model parameters as YAML config file")
    parser.add_argument(
        "-c",
        "--load-run-config",
        help="specify YAML file with run configuration to be loaded")
    parser.add_argument(
        "-m",
        "--load-model-config",
        help="specify YAML file with model configuration to be loaded")
    parser.add_argument("--debug",
                        action="store_true",
                        help="turn in debug information")
    parser.add_argument("--logfile", help="specify path to log file")

    args = parser.parse_args()

    configure_logger(args.debug, args.logfile)

    immediate_exit = False
    for k, v in {
            "run": args.dump_default_config,
            "models": args.dump_default_models
    }.items():
        if v is not None:
            Configuration.dump_default_config(k, v)
            immediate_exit = True
    if immediate_exit:
        sys.exit(0)

    #model_config = assert_model_config(args.load_model_config, run_config)

    conf = Configuration(args.load_run_config, args.load_model_config)
    conf.configure()

    conf.print_configuration()

    # Pass config dictionary
    doclassification_regression(conf)