def main(dataset, mode, seed, fold, folds):
    if seed is None:
        seed = 1

    if 'nested_cv' in mode:
        # Specifiy like this 5/5-nested-cv
        cv_match = re.match(r"([0-9]+)/([0-9]+)-nested_cv", mode)
        outer_folds = int(cv_match.group(1))
        inner_folds = int(cv_match.group(2))
        mode = 'nested_cv'
        mode_args = {'inner_folds': inner_folds, 'outer_folds': outer_folds}
    elif mode.endswith('cv'):
        if folds == 1:
            cv_match = re.match(r"([0-9]*)cv", mode)
            real_folds = cv_match.group(1)
            real_folds = 10 if not real_folds else int(real_folds)
            mode = 'cv'
            mode_args = {'folds': real_folds}
        else:
            mode = 'partial_cv'
            mode_args = {'fold': fold, 'folds': folds}
    elif mode == 'holdout':
        mode_args = None
    elif mode == 'test':
        mode_args = None
    else:
        raise ValueError(mode)

    base_interface.main(dataset, mode, seed, params, mode_args=mode_args)
def parse_args(dataset, mode, seed, params, fold, folds, output_dir=None):
    if seed is None:
        seed = 1

    if 'nested-cv' in mode:
        # Specifiy like this 5/5-nested-cv
        cv_match = re.match(r"([0-9]+)/([0-9]+)-nested-cv", mode)
        outer_folds = int(cv_match.group(1))
        inner_folds = int(cv_match.group(2))
        mode = 'nested-cv'
        mode_args = {'inner_folds': inner_folds, 'outer_folds': outer_folds}
    elif mode.endswith('cv'):
        if folds == 1:
            cv_match = re.match(r"([0-9]*)cv", mode)
            real_folds = cv_match.group(1)
            real_folds = 10 if not real_folds else int(real_folds)
            mode = 'cv'
            mode_args = {'folds': real_folds}
        else:
            mode = 'partial-cv'
            mode_args = {'fold': fold, 'folds': folds}
    elif mode in ('holdout', 'holdout-iterative-fit', 'test'):
        mode_args = None
    else:
        raise ValueError(mode)
    base_interface.main(dataset, mode, seed, params, mode_args=mode_args,
                        output_dir=output_dir)
Example #3
0
def main(output_dir=None):
    instance_name = sys.argv[1]
    instance_specific_information = sys.argv[2]
    cutoff_time = float(sys.argv[3])
    cutoff_length = int(float(sys.argv[4]))
    seed = int(float(sys.argv[5]))

    if seed < 0:
        seed = 1

    params = dict()
    for i in range(6, len(sys.argv), 2):
        p_name = str(sys.argv[i])
        if p_name[0].startswith('-'):
            p_name = p_name[1:]
        params[p_name] = sys.argv[i + 1].strip()

    if ":" in instance_name:
        instance_name = instance_name.split(":")
        mode = instance_name[0]
        mode_args = instance_name[1]
    else:
        mode = instance_name

    if mode in ('holdout', 'holdout-iterative-fit', 'test'):
        mode_args = None
    elif mode == 'nested-cv':
        mode_args = mode_args.split("/")
        inner_folds = int(mode_args[0])
        outer_folds = int(mode_args[1])
        mode_args = {'inner_folds': inner_folds, 'outer_folds': outer_folds}
    elif mode == 'partial-cv':
        mode_args = mode_args.split("/")
        fold = int(mode_args[0])
        folds = int(mode_args[1])
        mode_args = {'fold': fold, 'folds': folds}
    elif mode == 'cv':
        mode_args = {'folds': int(mode_args)}
    else:
        raise ValueError(mode)

    base_interface.main(instance_specific_information,
                        mode,
                        seed,
                        params,
                        mode_args=mode_args,
                        output_dir=output_dir)
Example #4
0
def main(output_dir=None):
    instance_name = sys.argv[1]
    instance_specific_information = sys.argv[2]
    cutoff_time = float(sys.argv[3])
    cutoff_length = int(float(sys.argv[4]))
    seed = int(float(sys.argv[5]))

    if seed < 0:
        seed = 1

    params = dict()
    for i in range(6, len(sys.argv), 2):
        p_name = str(sys.argv[i])
        if p_name[0].startswith('-'):
            p_name = p_name[1:]
        params[p_name] = sys.argv[i + 1].strip()

    if ":" in instance_name:
        instance_name = instance_name.split(":")
        mode = instance_name[0]
        mode_args = instance_name[1]
    else:
        mode = instance_name

    if mode in ('holdout', 'holdout-iterative-fit', 'test'):
        mode_args = None
    elif mode == 'nested-cv':
        mode_args = mode_args.split("/")
        inner_folds = int(mode_args[0])
        outer_folds = int(mode_args[1])
        mode_args = {'inner_folds': inner_folds, 'outer_folds': outer_folds}
    elif mode == 'partial-cv':
        mode_args = mode_args.split("/")
        fold = int(mode_args[0])
        folds = int(mode_args[1])
        mode_args = {'fold': fold, 'folds': folds}
    elif mode == 'cv':
        mode_args = {'folds': int(mode_args)}
    else:
        raise ValueError(mode)

    base_interface.main(instance_specific_information, mode,
                        seed, params, mode_args=mode_args, output_dir=output_dir)
Example #5
0
def main():
    instance_name = sys.argv[1]
    instance_specific_information = sys.argv[2]
    cutoff_time = float(sys.argv[3])
    cutoff_length = int(float(sys.argv[4]))
    seed = int(float(sys.argv[5]))

    if seed < 0:
        seed = 1

    params = dict()
    for i in range(6, len(sys.argv), 2):
        p_name = str(sys.argv[i])
        if p_name[0].startswith("-"):
            p_name = p_name[1:]
        params[p_name] = sys.argv[i + 1].strip()

    if ":" in instance_name:
        instance_name = instance_name.split(":")
        mode = instance_name[0]
        mode_args = instance_name[1]
    else:
        mode = instance_name

    if mode in ("holdout", "holdout-iterative-fit", "test"):
        mode_args = None
    elif mode == "nested-cv":
        mode_args = mode_args.split("/")
        inner_folds = int(mode_args[0])
        outer_folds = int(mode_args[1])
        mode_args = {"inner_folds": inner_folds, "outer_folds": outer_folds}
    elif mode == "partial-cv":
        mode_args = mode_args.split("/")
        fold = int(mode_args[0])
        folds = int(mode_args[1])
        mode_args = {"fold": fold, "folds": folds}
    elif mode == "cv":
        mode_args = {"folds": int(mode_args)}
    else:
        raise ValueError(mode)

    base_interface.main(instance_specific_information, mode, seed, params, mode_args=mode_args)
    seed = int(float(sys.argv[6]))

    if seed < 0:
        seed = 1

    params = dict()
    for i in range(7, len(sys.argv), 2):
        p_name = str(sys.argv[i])
        if p_name[0].startswith('-'):
            p_name = p_name[1:]
        params[p_name] = sys.argv[i + 1].strip()

    if instance_name == 'test':
        mode = 'test'
        mode_args = None
    else:
        mode = 'partial_cv'
        match = re.match(r"([0-9]+)/([0-9]+)", instance_name)
        if match:
            fold = int(match.group(1))
            folds = int(match.group(2))
        else:
            print('Result for ParamILS: %s, %f, 1, %f, %d, %s' %
                  ('ABORT', 0, 1.0, seed, 'Could not parse instance name!'))
            sys.exit(1)
        mode_args = {'fold': fold, 'folds': folds}

    base_interface.main(dataset_info, mode, seed, params, mode_args=mode_args)

    sys.exit(0)
Example #7
0
    seed = int(float(sys.argv[6]))

    if seed < 0:
        seed = 1

    params = dict()
    for i in range(7, len(sys.argv), 2):
        p_name = str(sys.argv[i])
        if p_name[0].startswith("-"):
            p_name = p_name[1:]
        params[p_name] = sys.argv[i + 1].strip()

    if instance_name == 'test':
        mode = 'test'
        mode_args = None
    else:
        mode = 'partial_cv'
        match = re.match(r"([0-9]+)/([0-9]+)", instance_name)
        if match:
            fold = int(match.group(1))
            folds = int(match.group(2))
        else:
            print "Result for ParamILS: %s, %f, 1, %f, %d, %s" % (
                "ABORT", 0, 1.0, seed, "Could not parse instance name!")
            sys.exit(1)
        mode_args = {'fold': fold, 'folds': folds}

    base_interface.main(dataset_info, mode, seed, params, mode_args=mode_args)

    sys.exit(0)