From 9eb0b9033cbed8e582f8f94d5bcafb3e63d2586a Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Fri, 13 Mar 2020 14:39:37 +0000 Subject: clarify warnings --- analysis/scripts/make_table.py | 5 +++-- analysis/scripts/rank_common.py | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'analysis/scripts') diff --git a/analysis/scripts/make_table.py b/analysis/scripts/make_table.py index e4747258..c326775e 100644 --- a/analysis/scripts/make_table.py +++ b/analysis/scripts/make_table.py @@ -310,7 +310,8 @@ def average_results(results): # remove RBOCPDMS for 'best', because it fails too often if experiment == Experiment.best: warning( - "\nWarning: Removing RBOCPDMS (experiment = %s)\n" % experiment + "\nWarning: Removing RBOCPDMS (experiment = %s) due to insufficient results\n" + % experiment ) results = list(filter(lambda r: r.method != Method.rbocpdms, results)) expected_methods.remove(Method.rbocpdms) @@ -322,7 +323,7 @@ def average_results(results): if any(r.score is None for r in dset_results): to_remove.append(dataset) if to_remove: - warning("\nWarning: Filtering out datasets: %r\n" % to_remove) + warning("\nWarning: Filtering out datasets: %r due to incomplete results for some detectors.\n" % to_remove) results = list(filter(lambda r: not r.dataset in to_remove, results)) # check that we are now complete: for all datasets and all methods in the diff --git a/analysis/scripts/rank_common.py b/analysis/scripts/rank_common.py index c47cac77..b1d5af77 100644 --- a/analysis/scripts/rank_common.py +++ b/analysis/scripts/rank_common.py @@ -8,12 +8,16 @@ License: See the LICENSE file. """ +import colorama import json import numpy as np import sys +import termcolor from scipy.stats import rankdata +colorama.init() + def load_data(filename): with open(filename, "r") as fp: @@ -78,13 +82,16 @@ def compute_ranks(results, keep_methods=None, higher_better=True): return avg_ranks, all_ranks +def warning(msg): + termcolor.cprint(msg, "yellow", file=sys.stderr) + + def preprocess_data(data, _type): methods = set([m for dset in data.keys() for m in data[dset].keys()]) methods = sorted(methods) if _type == "best": - print( - "\nWarning: Filtering out RBOCPDMS due to insufficient results.\n", - file=sys.stderr, + warning( + "\nWarning: Filtering out RBOCPDMS due to insufficient results.\n" ) methods = [m for m in methods if not m == "rbocpdms"] -- cgit v1.2.3