From 71704e3547f5dfbf8e3918d801338a9afa5f6128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Thu, 28 Sep 2023 01:27:18 +0200 Subject: [PATCH] Enhance output info in Statistics --- src/Platform/BestResults.cc | 1 - src/Platform/ReportBase.h | 13 ++----------- src/Platform/Statistics.cc | 21 +++++++++++++-------- src/Platform/Symbols.h | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 src/Platform/Symbols.h diff --git a/src/Platform/BestResults.cc b/src/Platform/BestResults.cc index 5c41d27..cc6f60d 100644 --- a/src/Platform/BestResults.cc +++ b/src/Platform/BestResults.cc @@ -2,7 +2,6 @@ #include #include #include -#include #include "BestResults.h" #include "Result.h" #include "Colors.h" diff --git a/src/Platform/ReportBase.h b/src/Platform/ReportBase.h index c8400cf..5797b1b 100644 --- a/src/Platform/ReportBase.h +++ b/src/Platform/ReportBase.h @@ -3,22 +3,13 @@ #include #include #include "Paths.h" +#include "Symbols.h" #include using json = nlohmann::json; namespace platform { using namespace std; - class Symbols { - public: - inline static const string check_mark{ "\u2714" }; - inline static const string exclamation{ "\u2757" }; - inline static const string black_star{ "\u2605" }; - inline static const string cross{ "\u2717" }; - inline static const string upward_arrow{ "\u27B6" }; - inline static const string down_arrow{ "\u27B4" }; - inline static const string equal_best{ check_mark }; - inline static const string better_best{ black_star }; - }; + class ReportBase { public: explicit ReportBase(json data_, bool compare); diff --git a/src/Platform/Statistics.cc b/src/Platform/Statistics.cc index f4d72f2..9a4a34f 100644 --- a/src/Platform/Statistics.cc +++ b/src/Platform/Statistics.cc @@ -1,5 +1,6 @@ #include "Statistics.h" #include "Colors.h" +#include "Symbols.h" #include #include @@ -24,7 +25,7 @@ namespace platform { computeWTL(); fitted = true; } - map assignRanks2(vector>& ranksOrder) + map assignRanks(vector>& ranksOrder) { // sort the ranksOrder vector by value sort(ranksOrder.begin(), ranksOrder.end(), [](const pair& a, const pair& b) { @@ -62,7 +63,7 @@ namespace platform { ranksOrder.push_back({ model, value }); } // Assign the ranks - ranksLine = assignRanks2(ranksOrder); + ranksLine = assignRanks(ranksOrder); if (ranks.size() == 0) { ranks = ranksLine; } else { @@ -139,13 +140,13 @@ namespace platform { p_value = max(before, p_value); statsOrder[i] = { item.first, p_value }; } - auto color = friedmanResult ? Colors::GREEN() : Colors::YELLOW(); + auto color = friedmanResult ? Colors::CYAN() : Colors::YELLOW(); cout << color; cout << " *************************************************************************************************************" << endl; cout << " Post-hoc Holm test: H0: 'There is no significant differences between the control model and the other models.'" << endl; cout << " Control model: " << models[controlIdx] << endl; - cout << " Model p-value rank win tie loss" << endl; - cout << " ============ ============ ========= === === ====" << endl; + cout << " Model p-value rank win tie loss Status" << endl; + cout << " ============ ============ ========= === === ==== =============" << endl; // sort ranks from lowest to highest vector> ranksOrder; for (const auto& rank : ranks) { @@ -165,10 +166,14 @@ namespace platform { pvalue = stat.second; } } - cout << " " << left << setw(12) << item.first << " " << setprecision(10) << fixed << pvalue << setprecision(7) << " " << item.second; - cout << " " << right << setw(3) << wtl.at(idx).win << " " << setw(3) << wtl.at(idx).tie << " " << setw(4) << wtl.at(idx).loss << endl; + auto colorStatus = pvalue > significance ? Colors::GREEN() : Colors::MAGENTA(); + auto status = pvalue > significance ? Symbols::check_mark : Symbols::cross; + auto textStatus = pvalue > significance ? " accepted H0" : " rejected H0"; + cout << " " << colorStatus << left << setw(12) << item.first << " " << setprecision(6) << scientific << pvalue << setprecision(7) << fixed << " " << item.second; + cout << " " << right << setw(3) << wtl.at(idx).win << " " << setw(3) << wtl.at(idx).tie << " " << setw(4) << wtl.at(idx).loss; + cout << " " << status << textStatus << endl; } - cout << " *************************************************************************************************************" << endl; + cout << color << " *************************************************************************************************************" << endl; cout << Colors::RESET(); } bool Statistics::friedmanTest() diff --git a/src/Platform/Symbols.h b/src/Platform/Symbols.h new file mode 100644 index 0000000..a9fa1e7 --- /dev/null +++ b/src/Platform/Symbols.h @@ -0,0 +1,18 @@ +#ifndef SYMBOLS_H +#define SYMBOLS_H +#include +using namespace std; +namespace platform { + class Symbols { + public: + inline static const string check_mark{ "\u2714" }; + inline static const string exclamation{ "\u2757" }; + inline static const string black_star{ "\u2605" }; + inline static const string cross{ "\u2717" }; + inline static const string upward_arrow{ "\u27B6" }; + inline static const string down_arrow{ "\u27B4" }; + inline static const string equal_best{ check_mark }; + inline static const string better_best{ black_star }; + }; +} +#endif // !SYMBOLS_H \ No newline at end of file