From 04e754b2f51be098e2fd7cd56aa54941450eab32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Fri, 20 Oct 2023 11:12:46 +0200 Subject: [PATCH] Adjust filename and hyperparameters in reports --- src/Platform/BestResults.cc | 12 ++++++++++-- src/Platform/BestResultsExcel.cc | 9 +-------- src/Platform/ReportConsole.cc | 6 +++++- src/Platform/ReportExcel.cc | 10 +--------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/Platform/BestResults.cc b/src/Platform/BestResults.cc index 27c4fd1..4a967a1 100644 --- a/src/Platform/BestResults.cc +++ b/src/Platform/BestResults.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include "BestResults.h" #include "Result.h" #include "Colors.h" @@ -155,12 +156,19 @@ namespace platform { auto data = loadFile(bestFileName); auto datasets = getDatasets(data); int maxDatasetName = (*max_element(datasets.begin(), datasets.end(), [](const string& a, const string& b) { return a.size() < b.size(); })).size(); + int maxFileName = 0; + int maxHyper = 0; + for (auto const& item : data.items()) { + maxHyper = max(maxHyper, (int)item.value().at(1).dump().size()); + maxFileName = max(maxFileName, (int)item.value().at(2).get().size()); + } + cout << "Hola" << endl; stringstream oss; oss << Colors::GREEN() << "Best results for " << model << " as of " << date << endl; cout << oss.str(); cout << string(oss.str().size() - 8, '-') << endl; cout << Colors::GREEN() << " # " << setw(maxDatasetName + 1) << left << string("Dataset") << "Score File Hyperparameters" << endl; - cout << "=== " << string(maxDatasetName, '=') << " =========== ================================================================== ================================================= " << endl; + cout << "=== " << string(maxDatasetName, '=') << " =========== " << string(maxFileName, '=') << " " << string(maxHyper, '=') << endl; auto i = 0; bool odd = true; double total = 0; @@ -170,7 +178,7 @@ namespace platform { cout << color << setw(3) << fixed << right << i++ << " "; cout << setw(maxDatasetName) << left << item.key() << " "; cout << setw(11) << setprecision(9) << fixed << value << " "; - cout << setw(66) << item.value().at(2).get() << " "; + cout << setw(maxFileName) << item.value().at(2).get() << " "; cout << item.value().at(1) << " "; cout << endl; total += value; diff --git a/src/Platform/BestResultsExcel.cc b/src/Platform/BestResultsExcel.cc index fb711ce..4a6a98a 100644 --- a/src/Platform/BestResultsExcel.cc +++ b/src/Platform/BestResultsExcel.cc @@ -60,14 +60,7 @@ namespace platform { writeString(row, 1, item.key().c_str(), "text"); writeDouble(row, 2, item.value().at(0).get(), "result"); writeString(row, 3, item.value().at(2).get(), "text"); - try { - hyperparameters = item.value().at(1).get(); - } - catch (const exception& err) { - stringstream oss; - oss << item.value().at(1); - hyperparameters = oss.str(); - } + hyperparameters = item.value().at(1).dump(); if (hyperparameters.size() > hypSize) { hypSize = hyperparameters.size(); } diff --git a/src/Platform/ReportConsole.cc b/src/Platform/ReportConsole.cc index c8e6890..822db4e 100644 --- a/src/Platform/ReportConsole.cc +++ b/src/Platform/ReportConsole.cc @@ -28,8 +28,12 @@ namespace platform { void ReportConsole::body() { auto tmp = ConfigLocale(); + int maxHyper = 0; + for (const auto& r : data["results"]) { + maxHyper = max(maxHyper, (int)r["hyperparameters"].dump().size()); + } cout << Colors::GREEN() << " # Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl; - cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== ====================" << endl; + cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== " << string(maxHyper, '=') << endl; json lastResult; double totalScore = 0.0; bool odd = true; diff --git a/src/Platform/ReportExcel.cc b/src/Platform/ReportExcel.cc index 13e0a9e..b2a900a 100644 --- a/src/Platform/ReportExcel.cc +++ b/src/Platform/ReportExcel.cc @@ -115,14 +115,7 @@ namespace platform { writeString(row, col + 9, status, "textCentered"); writeDouble(row, col + 10, r["time"].get(), "time"); writeDouble(row, col + 11, r["time_std"].get(), "time"); - try { - hyperparameters = r["hyperparameters"].get(); - } - catch (const exception& err) { - stringstream oss; - oss << r["hyperparameters"]; - hyperparameters = oss.str(); - } + hyperparameters = r["hyperparameters"].dump(); if (hyperparameters.size() > hypSize) { hypSize = hyperparameters.size(); } @@ -130,7 +123,6 @@ namespace platform { lastResult = r; totalScore += r["score"].get(); row++; - } // Set the right column width of hyperparameters with the maximum length worksheet_set_column(worksheet, 12, 12, hypSize + 5, NULL);