def _calculate_meta_features_encoded(basename, x_train, y_train, watcher, log_funciton): task_name = 'CalculateMetafeaturesEncoded' watcher.start_task(task_name) result = calc_meta_features_encoded(X_train=x_train, Y_train=y_train, categorical=[False] * x_train.shape[0], dataset_name=basename) watcher.stop_task(task_name) log_funciton( 'Calculating Metafeatures (encoded attributes) took %5.2fsec' % watcher.wall_elapsed(task_name)) return result
def test_metalearning(self): dataset_name = 'digits' initial_challengers = { 'acc_metric': ["--initial-challengers \" " "-adaboost:algorithm 'SAMME.R' " "-adaboost:learning_rate '0.400363929326' " "-adaboost:max_depth '5' " "-adaboost:n_estimators '319' " "-balancing:strategy 'none' " "-classifier 'adaboost' " "-imputation:strategy 'most_frequent' " "-preprocessor 'no_preprocessing' " "-rescaling:strategy 'min/max'\""], 'auc_metric': ["--initial-challengers \" " "-adaboost:algorithm 'SAMME.R' " "-adaboost:learning_rate '0.966883114819' " "-adaboost:max_depth '5' " "-adaboost:n_estimators '412' " "-balancing:strategy 'weighting' " "-classifier 'adaboost' " "-imputation:strategy 'median' " "-preprocessor 'no_preprocessing' " "-rescaling:strategy 'min/max'\""], 'bac_metric': ["--initial-challengers \" " "-adaboost:algorithm 'SAMME.R' " "-adaboost:learning_rate '0.400363929326' " "-adaboost:max_depth '5' " "-adaboost:n_estimators '319' " "-balancing:strategy 'none' " "-classifier 'adaboost' " "-imputation:strategy 'most_frequent' " "-preprocessor 'no_preprocessing' " "-rescaling:strategy 'min/max'\""], 'f1_metric': ["--initial-challengers \" " "-adaboost:algorithm 'SAMME.R' " "-adaboost:learning_rate '0.966883114819' " "-adaboost:max_depth '5' " "-adaboost:n_estimators '412' " "-balancing:strategy 'weighting' " "-classifier 'adaboost' " "-imputation:strategy 'median' " "-preprocessor 'no_preprocessing' " "-rescaling:strategy 'min/max'\""], 'pac_metric': ["--initial-challengers \" " "-adaboost:algorithm 'SAMME.R' " "-adaboost:learning_rate '0.400363929326' " "-adaboost:max_depth '5' " "-adaboost:n_estimators '319' " "-balancing:strategy 'none' " "-classifier 'adaboost' " "-imputation:strategy 'most_frequent' " "-preprocessor 'no_preprocessing' " "-rescaling:strategy 'min/max'\""] } for metric in initial_challengers: configuration_space = get_configuration_space( { 'metric': metric, 'task': MULTICLASS_CLASSIFICATION, 'is_sparse': False }, include_preprocessors=['no_preprocessing']) X_train, Y_train, X_test, Y_test = get_dataset(dataset_name) categorical = [False] * X_train.shape[1] meta_features_label = calc_meta_features(X_train, Y_train, categorical, dataset_name) meta_features_encoded_label = calc_meta_features_encoded(X_train, Y_train, categorical, dataset_name) initial_configuration_strings_for_smac = \ create_metalearning_string_for_smac_call( meta_features_label, meta_features_encoded_label, configuration_space, dataset_name, metric, MULTICLASS_CLASSIFICATION, False, 1, None) print(metric) self.assertEqual(initial_challengers[metric], initial_configuration_strings_for_smac)