Exemplo n.º 1
0
def suggest_via_metalearning(meta_base, dataset_name, metric, task, sparse,
                             num_initial_configurations):
    logger = get_logger('autosklearn.metalearning.mismbo')

    if task == MULTILABEL_CLASSIFICATION:
        task = MULTICLASS_CLASSIFICATION

    task = TASK_TYPES_TO_STRING[task]

    logger.warning(task)

    start = time.time()
    ml = MetaLearningOptimizer(
        dataset_name=dataset_name,
        configuration_space=meta_base.configuration_space,
        meta_base=meta_base,
        distance='l1',
        seed=1,
    )
    logger.info('Reading meta-data took %5.2f seconds', time.time() - start)
    runs = ml.metalearning_suggest_all(exclude_double_configurations=True)
    return runs[:num_initial_configurations]
Exemplo n.º 2
0
def suggest_via_metalearning(
        meta_base, dataset_name, metric, task, sparse,
        num_initial_configurations):
    logger = get_logger('autosklearn.metalearning.mismbo')

    if task == MULTILABEL_CLASSIFICATION:
        task = MULTICLASS_CLASSIFICATION

    task = TASK_TYPES_TO_STRING[task]

    logger.warning(task)

    start = time.time()
    ml = MetaLearningOptimizer(
        dataset_name=dataset_name,
        configuration_space=meta_base.configuration_space,
        meta_base=meta_base,
        distance='l1',
        seed=1,)
    logger.info('Reading meta-data took %5.2f seconds',
                time.time() - start)
    runs = ml.metalearning_suggest_all(exclude_double_configurations=True)
    return runs[:num_initial_configurations]
Exemplo n.º 3
0
def create_metalearning_string_for_smac_call(metafeatures_labels,
                                             metafeatures_encoded_labels,
                                             configuration_space, dataset_name,
                                             metric, task, sparse,
                                             num_initial_configurations,
                                             metadata_directory):
    """

    :param metafeatures_labels:
    :param metafeatures_encoded_labels:
    :param configuration_space:
    :param dataset_name:
    :param metric:
    :param task:
    :param sparse:
    :param num_initial_configurations:
    :param metadata_directory:
    :return:
    """
    logger = get_logger('autosklearn.metalearning.mismbo')

    task = task if task != MULTILABEL_CLASSIFICATION else MULTICLASS_CLASSIFICATION
    task = TASK_TYPES_TO_STRING[task]

    if metafeatures_encoded_labels is None or \
                    metafeatures_labels is None:
        raise ValueError('Please call '
                         'calculate_metafeatures_encoded_labels and '
                         'calculate_metafeatures_with_labels first!')

    logger.warning(task)
    current_directory = os.path.dirname(__file__)
    if metadata_directory is None:
        metadata_directory = os.path.join(
            current_directory, 'files',
            '%s_%s_%s' % (METRIC_TO_STRING[metric], task,
                          'sparse' if sparse is True else 'dense'))
    logger.warning(metadata_directory)
    # Concatenate the metafeatures!
    mf = metafeatures_labels
    mf.metafeature_values.update(
        metafeatures_encoded_labels.metafeature_values)

    metafeatures_subset = subsets['all']
    metafeatures_subset.difference_update(EXCLUDE_META_FUTURES)
    metafeatures_subset = list(metafeatures_subset)

    start = time.time()
    ml = MetaLearningOptimizer(dataset_name=dataset_name + SENTINEL,
                               configuration_space=configuration_space,
                               aslib_directory=metadata_directory,
                               distance='l1',
                               seed=1,
                               use_features=metafeatures_subset,
                               subset='all')
    logger.info('Reading meta-data took %5.2f seconds', time.time() - start)
    # TODO This is hacky, I must find a different way of adding a new
    # dataset!
    ml.meta_base.add_dataset(dataset_name + SENTINEL, mf)
    runs = ml.metalearning_suggest_all(exclude_double_configurations=True)

    # = Convert these configurations into the SMAC CLI configuration format
    smac_initial_configuration_strings = []

    for configuration in runs[:num_initial_configurations]:
        smac_initial_configuration_strings.append(
            convert_conf2smac_string(configuration))

    return smac_initial_configuration_strings
Exemplo n.º 4
0
def create_metalearning_string_for_smac_call(
        metafeatures_labels, metafeatures_encoded_labels,
        configuration_space, dataset_name, metric, task, sparse,
        num_initial_configurations, metadata_directory):
    """

    :param metafeatures_labels:
    :param metafeatures_encoded_labels:
    :param configuration_space:
    :param dataset_name:
    :param metric:
    :param task:
    :param sparse:
    :param num_initial_configurations:
    :param metadata_directory:
    :return:
    """
    logger = get_logger('autosklearn.metalearning.mismbo')

    task = TASK_TYPES_TO_STRING[task]

    if metafeatures_encoded_labels is None or \
                    metafeatures_labels is None:
        raise ValueError('Please call '
                         'calculate_metafeatures_encoded_labels and '
                         'calculate_metafeatures_with_labels first!')

    current_directory = os.path.dirname(__file__)
    if metadata_directory is None:
        metadata_directory = os.path.join(
            current_directory, 'files',
            '%s_%s_%s' % (METRIC_TO_STRING[metric], task,
                          'sparse' if sparse is True else 'dense'))

    # Concatenate the metafeatures!
    mf = metafeatures_labels
    mf.metafeature_values.update(
        metafeatures_encoded_labels.metafeature_values)

    metafeatures_subset = subsets['all']
    metafeatures_subset.difference_update(EXCLUDE_META_FUTURES)
    metafeatures_subset = list(metafeatures_subset)

    start = time.time()
    ml = MetaLearningOptimizer(
        dataset_name=dataset_name + SENTINEL,
        configuration_space=configuration_space,
        aslib_directory=metadata_directory,
        distance='l1',
        seed=1,
        use_features=metafeatures_subset,
        subset='all')
    logger.info('Reading meta-data took %5.2f seconds',
                time.time() - start)
    # TODO This is hacky, I must find a different way of adding a new
    # dataset!
    ml.meta_base.add_dataset(dataset_name + SENTINEL, mf)
    runs = ml.metalearning_suggest_all(exclude_double_configurations=True)

    # = Convert these configurations into the SMAC CLI configuration format
    smac_initial_configuration_strings = []

    for configuration in runs[:num_initial_configurations]:
        smac_initial_configuration_strings.append(
            convert_conf2smac_string(configuration))

    return smac_initial_configuration_strings