From 96ff6093361a5e5df0db0b8d185deef19748e425 Mon Sep 17 00:00:00 2001 From: Charly Lamothe <charly.lamothe@univ-amu.fr> Date: Tue, 10 Mar 2020 15:32:53 +0100 Subject: [PATCH] Fix normalize_D missing transpose and fix stage4 result path --- code/bolsonaro/models/omp_forest.py | 4 ++++ code/bolsonaro/models/omp_forest_classifier.py | 4 ++++ code/compute_results.py | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/bolsonaro/models/omp_forest.py b/code/bolsonaro/models/omp_forest.py index e4a5667..6c9a3f9 100644 --- a/code/bolsonaro/models/omp_forest.py +++ b/code/bolsonaro/models/omp_forest.py @@ -123,7 +123,9 @@ class SingleOmpForest(OmpForest): forest_predictions = self._base_estimator_predictions(X) if self._models_parameters.normalize_D: + forest_predictions = forest_predictions.T forest_predictions /= self._forest_norms + forest_predictions = forest_predictions.T return self._make_omp_weighted_prediction(forest_predictions, self._omp, self._models_parameters.normalize_weights) @@ -139,7 +141,9 @@ class SingleOmpForest(OmpForest): forest_predictions = self._base_estimator_predictions(X).T if self._models_parameters.normalize_D: + forest_predictions = forest_predictions.T forest_predictions /= self._forest_norms + forest_predictions = forest_predictions.T weights = self._omp.coef_ omp_trees_indices = np.nonzero(weights)[0] diff --git a/code/bolsonaro/models/omp_forest_classifier.py b/code/bolsonaro/models/omp_forest_classifier.py index a51405a..3cb250d 100644 --- a/code/bolsonaro/models/omp_forest_classifier.py +++ b/code/bolsonaro/models/omp_forest_classifier.py @@ -37,7 +37,9 @@ class OmpForestBinaryClassifier(SingleOmpForest): forest_predictions = np.array([tree.predict_proba(X) for tree in self._base_forest_estimator.estimators_]) if self._models_parameters.normalize_D: + forest_predictions = forest_predictions.T forest_predictions /= self._forest_norms + forest_predictions = forest_predictions.T weights = self._omp.coef_ omp_trees_indices = np.nonzero(weights) @@ -119,7 +121,9 @@ class OmpForestMulticlassClassifier(OmpForest): forest_predictions = np.array([tree.predict_proba(X) for tree in self._base_forest_estimator.estimators_]).T if self._models_parameters.normalize_D: + forest_predictions = forest_predictions.T forest_predictions /= self._forest_norms + forest_predictions = forest_predictions.T label_names = [] preds = [] diff --git a/code/compute_results.py b/code/compute_results.py index 406f0e0..a6eb2f5 100644 --- a/code/compute_results.py +++ b/code/compute_results.py @@ -389,7 +389,7 @@ if __name__ == "__main__": raise ValueError('Score metrics of all experiments must be the same.') experiments_score_metric = base_with_params_experiment_score_metric - output_path = os.path.join(args.results_dir, args.dataset_name, 'stage4_fix') + output_path = os.path.join(args.results_dir, args.dataset_name, 'stage4') pathlib.Path(output_path).mkdir(parents=True, exist_ok=True) Plotter.plot_stage2_losses( -- GitLab