From 07a2efb2988e6514eca4cdb65e610e3850d3b354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Sun, 12 May 2024 12:52:22 +0200 Subject: [PATCH] Show classification report in b_manage --- src/main/Experiment.cpp | 2 +- src/reports/ReportConsole.cpp | 13 +++++++++---- src/reports/ReportConsole.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/Experiment.cpp b/src/main/Experiment.cpp index e006821..dcca794 100644 --- a/src/main/Experiment.cpp +++ b/src/main/Experiment.cpp @@ -16,7 +16,7 @@ namespace platform { ReportConsole report(result.getJson()); report.show(); if (classification_report) { - report.showClassificationReport(); + std::cout << Colors::BLUE() << report.showClassificationReport() << Colors::RESET(); } } void Experiment::show() diff --git a/src/reports/ReportConsole.cpp b/src/reports/ReportConsole.cpp index c3d5c82..f029fc4 100644 --- a/src/reports/ReportConsole.cpp +++ b/src/reports/ReportConsole.cpp @@ -129,11 +129,15 @@ namespace platform { vbody.push_back(line.str()); sbody << line.str(); line.str(""); line << headerLine(fVector("Test times: ", lastResult["times_test"], 10, 3)); vbody.push_back(line.str()); sbody << line.str(); + } else { footer(totalScore); } sbody << std::string(MAXL, '*') << Colors::RESET() << std::endl; vbody.push_back(std::string(MAXL, '*') + Colors::RESET() + "\n"); + if (lastResult.find("confusion_matrices") != lastResult.end() && (data["results"].size() == 1 || selectedIndex != -1)) { + vbody.push_back(Colors::BLUE() + showClassificationReport() + Colors::RESET()); + } } void ReportConsole::showSummary() { @@ -165,16 +169,17 @@ namespace platform { std::cout << headerLine("*** Best Results File not found. Couldn't compare any result!"); } } - void ReportConsole::showClassificationReport() + std::string ReportConsole::showClassificationReport() { - if (data["results"].size() > 1) - return; + auto lastResult = data["results"][0]; + if (data["results"].size() > 1 || lastResult.find("confusion_matrices") == lastResult.end()) + return ""; auto item = data["results"][0]; auto scores = Scores(item["confusion_matrices"][0]); for (int i = 1; i < item["confusion_matrices"].size(); i++) { auto score = Scores(item["confusion_matrices"][i]); scores.aggregate(score); } - std::cout << Colors::BLUE() << scores.classification_report() << Colors::RESET(); + return scores.classification_report(); } } \ No newline at end of file diff --git a/src/reports/ReportConsole.h b/src/reports/ReportConsole.h index c6ba6d6..c85cc39 100644 --- a/src/reports/ReportConsole.h +++ b/src/reports/ReportConsole.h @@ -14,7 +14,7 @@ namespace platform { std::string fileReport(); std::string getHeader() { do_header(); do_body(); return sheader.str(); } std::vector& getBody() { return vbody; } - void showClassificationReport(); + std::string showClassificationReport(); private: int selectedIndex; std::string headerLine(const std::string& text, int utf);