Show classification report in b_manage

This commit is contained in:
2024-05-12 12:52:22 +02:00
parent f88b223c46
commit 07a2efb298
3 changed files with 11 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ namespace platform {
ReportConsole report(result.getJson()); ReportConsole report(result.getJson());
report.show(); report.show();
if (classification_report) { if (classification_report) {
report.showClassificationReport(); std::cout << Colors::BLUE() << report.showClassificationReport() << Colors::RESET();
} }
} }
void Experiment::show() void Experiment::show()

View File

@@ -129,11 +129,15 @@ namespace platform {
vbody.push_back(line.str()); sbody << line.str(); vbody.push_back(line.str()); sbody << line.str();
line.str(""); line << headerLine(fVector("Test times: ", lastResult["times_test"], 10, 3)); line.str(""); line << headerLine(fVector("Test times: ", lastResult["times_test"], 10, 3));
vbody.push_back(line.str()); sbody << line.str(); vbody.push_back(line.str()); sbody << line.str();
} else { } else {
footer(totalScore); footer(totalScore);
} }
sbody << std::string(MAXL, '*') << Colors::RESET() << std::endl; sbody << std::string(MAXL, '*') << Colors::RESET() << std::endl;
vbody.push_back(std::string(MAXL, '*') + Colors::RESET() + "\n"); 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() void ReportConsole::showSummary()
{ {
@@ -165,16 +169,17 @@ namespace platform {
std::cout << headerLine("*** Best Results File not found. Couldn't compare any result!"); 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) auto lastResult = data["results"][0];
return; if (data["results"].size() > 1 || lastResult.find("confusion_matrices") == lastResult.end())
return "";
auto item = data["results"][0]; auto item = data["results"][0];
auto scores = Scores(item["confusion_matrices"][0]); auto scores = Scores(item["confusion_matrices"][0]);
for (int i = 1; i < item["confusion_matrices"].size(); i++) { for (int i = 1; i < item["confusion_matrices"].size(); i++) {
auto score = Scores(item["confusion_matrices"][i]); auto score = Scores(item["confusion_matrices"][i]);
scores.aggregate(score); scores.aggregate(score);
} }
std::cout << Colors::BLUE() << scores.classification_report() << Colors::RESET(); return scores.classification_report();
} }
} }

View File

@@ -14,7 +14,7 @@ namespace platform {
std::string fileReport(); std::string fileReport();
std::string getHeader() { do_header(); do_body(); return sheader.str(); } std::string getHeader() { do_header(); do_body(); return sheader.str(); }
std::vector<std::string>& getBody() { return vbody; } std::vector<std::string>& getBody() { return vbody; }
void showClassificationReport(); std::string showClassificationReport();
private: private:
int selectedIndex; int selectedIndex;
std::string headerLine(const std::string& text, int utf); std::string headerLine(const std::string& text, int utf);