diff --git a/code/bolsonaro/trainer.py b/code/bolsonaro/trainer.py index 1cf9346c3e94f607cff3c61204254884d66a8766..56cb79aeec92e4889f0f68730ae1329b03584c98 100644 --- a/code/bolsonaro/trainer.py +++ b/code/bolsonaro/trainer.py @@ -137,6 +137,8 @@ class Trainer(object): y_pred = model.predict(X, extracted_forest_size) else: y_pred = model.predict_no_weights(X, extracted_forest_size) + y_pred = np.sign(y_pred) + y_pred = np.where(y_pred == 0, 1, y_pred) result = self._classification_score_metric(y_true, y_pred) elif type(model) in [OmpForestBinaryClassifier, OmpForestMulticlassClassifier, RandomForestClassifier]: if weights: diff --git a/code/prepare_models.py b/code/prepare_models.py index 519105ff98535dfc25cb8a85a23ea9fda40fcd32..9f2c955689784b454fde4439179aa1d180d25856 100644 --- a/code/prepare_models.py +++ b/code/prepare_models.py @@ -7,10 +7,12 @@ from tqdm import tqdm if __name__ == "__main__": models_source_path = 'models' - models_destination_path = 'bolsonaro_models_27-03-20_v2' + models_destination_path = 'bolsonaro_models_29-03-20' datasets = ['boston', 'diabetes', 'linnerud', 'breast_cancer', 'california_housing', 'diamonds', 'steel-plates', 'kr-vs-kp', 'kin8nm', 'spambase', 'gamma', 'lfw_pairs'] + datasets = ['california_housing', 'boston', 'diabetes', 'breast_cancer', 'diamonds', 'steel-plates'] + pathlib.Path(models_destination_path).mkdir(parents=True, exist_ok=True) with tqdm(datasets) as dataset_bar: @@ -18,12 +20,16 @@ if __name__ == "__main__": dataset_bar.set_description(dataset) found_paths = glob2.glob(os.path.join(models_source_path, dataset, 'stage5_27-03-20', '**', 'model_raw_results.pickle'), recursive=True) - pathlib.Path(os.path.join(models_destination_path, dataset)).mkdir(parents=True, exist_ok=True) + #pathlib.Path(os.path.join(models_destination_path, dataset)).mkdir(parents=True, exist_ok=True) with tqdm(found_paths) as found_paths_bar: for path in found_paths_bar: found_paths_bar.set_description(path) new_path = path.replace(f'models/{dataset}/stage5_27-03-20/', '') (new_path, filename) = os.path.split(new_path) + if int(new_path.split(os.sep)[0]) != 9: + found_paths_bar.update(1) + found_paths_bar.set_description('Skipping...') + continue new_path = os.path.join(models_destination_path, dataset, new_path) pathlib.Path(new_path).mkdir(parents=True, exist_ok=True) shutil.copyfile(src=path, dst=os.path.join(new_path, filename))