Exemplo n.º 1
0
def _test_config_44(data_rnd_seed_values,
                    noise_values,
                    results_dir="results/synthetic_data"):
    """Testing configuration for the changing amount of noise experiment.
    
    Parameters
    ----------
    data_rnd_seed_values : list
        Values of data_rnd_seed for which to repeat the experiment.
    noise_values : list
        Values of the amount of noise for which to repeat the experiment.
    results_dir : str
        Directory in which to put the chaning_noise directory with the relevant
        experiment results.
    
    """
    # parameters of the synthetic Boolean MTL problem
    attributes = 12
    disjunct_degree = 6
    n = 50
    task_groups = 5
    tasks_per_group = 5
    noise = 0.0
    n_learning_sets = 10
    # parameters of the MTL problem tester
    rnd_seed = 51

    # dynamic parameters of the synthetic Boolean MTL problem

    for data_rnd_seed in data_rnd_seed_values:
        results_path_fmt = os.path.join(
            path_prefix, results_dir,
            "changing_noise/bool_func-a{}d{}n{}g{}tg{}"
            "nse{{}}rs{}nls{}-seed{}-complete_test".format(
                attributes, disjunct_degree, n, task_groups, tasks_per_group,
                data_rnd_seed, n_learning_sets, rnd_seed))
        if "run" in mode:
            for noise in noise_values:
                # prepare directories and loggers
                results_path = results_path_fmt.format(noise)
                if not os.path.exists(results_path):
                    os.makedirs(results_path)
                log_file = os.path.join(results_path, "run-{}.log".\
                            format(time.strftime("%Y%m%d_%H%M%S")))
                configure_logger(logger,
                                 console_level=logging.INFO,
                                 file_name=log_file)
                log_base_learner_info(logger, base_learners_bool)
                # generate boolean data with complete test sets
                funcs_pickle_path = os.path.join(results_path,
                                                 "boolean_funcs.pkl")
                tasks_data, tasks_complete_test_sets = \
                    synthetic_data.generate_boolean_data_with_complete_test_sets(
                        attributes, disjunct_degree, n, task_groups,
                        tasks_per_group, noise,
                        random_seed=data_rnd_seed,
                        n_learning_sets=n_learning_sets,
                        funcs_pickle_path=funcs_pickle_path)
                # test the generated MTL problem
                test_tasks(tasks_data,
                           results_path,
                           base_learners_bool,
                           measures_clas,
                           learners,
                           "pre-prepared_test",
                           rnd_seed=rnd_seed,
                           test=test,
                           unpickle=unpickle,
                           visualize=visualize,
                           preprepared_test_sets=tasks_complete_test_sets,
                           separate_figs=True,
                           cfg_logger=False)
        if "combine" in mode:
            combine_experiment_results(
                results_path_fmt,
                noise_values,
                (results_path_fmt.format(pprint_iter(noise_values)) +
                 "-{}-{{}}.pdf".format(error_measure)),
                n_learning_sets,
                error_measure=error_measure,
                title="Avg. results for tasks",
                xlabel="% of noise")
Exemplo n.º 2
0
def _test_config_44(data_rnd_seed_values, noise_values,
                    results_dir="results/synthetic_data"):
    """Testing configuration for the changing amount of noise experiment.
    
    Parameters
    ----------
    data_rnd_seed_values : list
        Values of data_rnd_seed for which to repeat the experiment.
    noise_values : list
        Values of the amount of noise for which to repeat the experiment.
    results_dir : str
        Directory in which to put the chaning_noise directory with the relevant
        experiment results.
    
    """
    # parameters of the synthetic Boolean MTL problem
    attributes = 12
    disjunct_degree = 6
    n = 50
    task_groups = 5
    tasks_per_group = 5
    noise = 0.0
    n_learning_sets = 10
    # parameters of the MTL problem tester
    rnd_seed = 51
    
    # dynamic parameters of the synthetic Boolean MTL problem
    
    
    for data_rnd_seed in data_rnd_seed_values:
        results_path_fmt = os.path.join(path_prefix, results_dir,
            "changing_noise/bool_func-a{}d{}n{}g{}tg{}"
            "nse{{}}rs{}nls{}-seed{}-complete_test".format(attributes,
            disjunct_degree, n, task_groups, tasks_per_group,
            data_rnd_seed, n_learning_sets, rnd_seed))
        if "run" in mode:
            for noise in noise_values:
                # prepare directories and loggers
                results_path = results_path_fmt.format(noise)
                if not os.path.exists(results_path):
                    os.makedirs(results_path)
                log_file = os.path.join(results_path, "run-{}.log".\
                            format(time.strftime("%Y%m%d_%H%M%S")))
                configure_logger(logger, console_level=logging.INFO,
                                 file_name=log_file)
                log_base_learner_info(logger, base_learners_bool)
                # generate boolean data with complete test sets
                funcs_pickle_path = os.path.join(results_path,
                                                 "boolean_funcs.pkl")
                tasks_data, tasks_complete_test_sets = \
                    synthetic_data.generate_boolean_data_with_complete_test_sets(
                        attributes, disjunct_degree, n, task_groups,
                        tasks_per_group, noise,
                        random_seed=data_rnd_seed,
                        n_learning_sets=n_learning_sets,
                        funcs_pickle_path=funcs_pickle_path)
                # test the generated MTL problem
                test_tasks(tasks_data, results_path, base_learners_bool,
                           measures_clas, learners, "pre-prepared_test",
                           rnd_seed=rnd_seed, test=test,
                           unpickle=unpickle, visualize=visualize,
                           preprepared_test_sets=tasks_complete_test_sets,
                           separate_figs=True, cfg_logger=False)
        if "combine" in mode:
            combine_experiment_results(results_path_fmt,
                noise_values,
                (results_path_fmt.format(pprint_iter(noise_values)) +
                 "-{}-{{}}.pdf".format(error_measure)),
                n_learning_sets, error_measure=error_measure,
                title="Avg. results for tasks", xlabel="% of noise")
Exemplo n.º 3
0
                             file_name=log_file)
            tasks_data = synthetic_data.generate_boolean_data(
                attributes,
                disjunct_degree,
                n,
                task_groups,
                tasks_per_group,
                noise,
                random_seed=data_rnd_seed)
            test_tasks(tasks_data,
                       results_path,
                       base_learners_bool,
                       measures_clas,
                       learners,
                       "train_test_split",
                       rnd_seed=rnd_seed,
                       test=test,
                       unpickle=unpickle,
                       visualize=visualize,
                       test_prop=test_prop,
                       repeats=repeats,
                       cfg_logger=False,
                       separate_figs=True)

        if test_config == 21:
            # parameters of the synthetic Boolean MTL problem
            attributes = 8
            disjunct_degree = 4
            n = 100
            task_groups = 2
            tasks_per_group = 5
            noise = 0.0
Exemplo n.º 4
0
     results_path = os.path.join(path_prefix, "results/synthetic_data/"
                     "boolean_func-a{}d{}n{}g{}tg{}-seed{}-repeats{}".\
                     format(attributes, disjunct_degree, n, task_groups,
                            tasks_per_group, rnd_seed, repeats))
     if not os.path.exists(results_path):
         os.makedirs(results_path)
     log_file = os.path.join(results_path,
                     "run-{}.log".format(time.strftime("%Y%m%d_%H%M%S")))
     configure_logger(logger, console_level=logging.INFO,
                      file_name=log_file)
     tasks_data = synthetic_data.generate_boolean_data(attributes,
                     disjunct_degree, n, task_groups, tasks_per_group,
                     noise, random_seed=data_rnd_seed)
     test_tasks(tasks_data, results_path, base_learners_bool,
                measures_clas, learners, "train_test_split",
                rnd_seed=rnd_seed,
                test=test, unpickle=unpickle, visualize=visualize,
                test_prop=test_prop, repeats=repeats, cfg_logger=False,
                separate_figs=True)
 
 if test_config == 21:
     # parameters of the synthetic Boolean MTL problem
     attributes = 8
     disjunct_degree = 4
     n = 100
     task_groups = 2
     tasks_per_group = 5
     noise = 0.0
     data_rnd_seed = 11
     n_learning_sets = 3
     # parameters of the MTL problem tester
     rnd_seed = 51