From 337b6f7e79f61bf6584f4becb1e873149fc89860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Thu, 21 Sep 2023 19:30:07 +0200 Subject: [PATCH] Rename BestResult to BestScore --- src/Platform/{BestResult.h => BestScore.h} | 6 +-- src/Platform/CMakeLists.txt | 1 + src/Platform/ReportBase.cc | 2 +- src/Platform/ReportConsole.cc | 6 +-- src/Platform/ReportExcel.cc | 8 ++-- src/Platform/Results.cc | 6 +-- src/Platform/best.cc | 52 ++++++++++++++++++++++ 7 files changed, 67 insertions(+), 14 deletions(-) rename src/Platform/{BestResult.h => BestScore.h} (77%) create mode 100644 src/Platform/best.cc diff --git a/src/Platform/BestResult.h b/src/Platform/BestScore.h similarity index 77% rename from src/Platform/BestResult.h rename to src/Platform/BestScore.h index 8b3f1cb..4e649b2 100644 --- a/src/Platform/BestResult.h +++ b/src/Platform/BestScore.h @@ -1,7 +1,7 @@ -#ifndef BESTRESULT_H -#define BESTRESULT_H +#ifndef BESTSCORE_H +#define BESTSCORE_H #include -class BestResult { +class BestScore { public: static std::string title() { return "STree_default (linear-ovo)"; } static double score() { return 22.109799; } diff --git a/src/Platform/CMakeLists.txt b/src/Platform/CMakeLists.txt index 071577f..2b899ea 100644 --- a/src/Platform/CMakeLists.txt +++ b/src/Platform/CMakeLists.txt @@ -8,6 +8,7 @@ include_directories(${BayesNet_SOURCE_DIR}/lib/libxlsxwriter/include) add_executable(main main.cc Folding.cc platformUtils.cc Experiment.cc Datasets.cc Models.cc ReportConsole.cc ReportBase.cc) add_executable(manage manage.cc Results.cc ReportConsole.cc ReportExcel.cc ReportBase.cc Datasets.cc platformUtils.cc) add_executable(list list.cc platformUtils Datasets.cc) +add_executable(best list.cc platformUtils Datasets.cc) target_link_libraries(main BayesNet ArffFiles mdlp "${TORCH_LIBRARIES}") if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux") target_link_libraries(manage "${TORCH_LIBRARIES}" libxlsxwriter.so ArffFiles mdlp stdc++fs) diff --git a/src/Platform/ReportBase.cc b/src/Platform/ReportBase.cc index 702c3f0..3cac9d3 100644 --- a/src/Platform/ReportBase.cc +++ b/src/Platform/ReportBase.cc @@ -2,7 +2,7 @@ #include #include "Datasets.h" #include "ReportBase.h" -#include "BestResult.h" +#include "BestScore.h" namespace platform { diff --git a/src/Platform/ReportConsole.cc b/src/Platform/ReportConsole.cc index 621f463..daf6242 100644 --- a/src/Platform/ReportConsole.cc +++ b/src/Platform/ReportConsole.cc @@ -1,7 +1,7 @@ #include #include #include "ReportConsole.h" -#include "BestResult.h" +#include "BestScore.h" namespace platform { @@ -99,9 +99,9 @@ namespace platform { cout << Colors::MAGENTA() << string(MAXL, '*') << endl; showSummary(); auto score = data["score_name"].get(); - if (score == BestResult::scoreName()) { + if (score == BestScore::scoreName()) { stringstream oss; - oss << score << " compared to " << BestResult::title() << " .: " << totalScore / BestResult::score(); + oss << score << " compared to " << BestScore::title() << " .: " << totalScore / BestScore::score(); cout << headerLine(oss.str()); } if (!getExistBestFile() && compare) { diff --git a/src/Platform/ReportExcel.cc b/src/Platform/ReportExcel.cc index 1b6d74e..9398185 100644 --- a/src/Platform/ReportExcel.cc +++ b/src/Platform/ReportExcel.cc @@ -1,7 +1,7 @@ #include #include #include "ReportExcel.h" -#include "BestResult.h" +#include "BestScore.h" namespace platform { @@ -322,9 +322,9 @@ namespace platform { showSummary(); row += 4 + summary.size(); auto score = data["score_name"].get(); - if (score == BestResult::scoreName()) { - worksheet_merge_range(worksheet, row, 1, row, 5, (score + " compared to " + BestResult::title() + " .:").c_str(), efectiveStyle("text")); - writeDouble(row, 6, totalScore / BestResult::score(), "result"); + if (score == BestScore::scoreName()) { + worksheet_merge_range(worksheet, row, 1, row, 5, (score + " compared to " + BestScore::title() + " .:").c_str(), efectiveStyle("text")); + writeDouble(row, 6, totalScore / BestScore::score(), "result"); } if (!getExistBestFile() && compare) { worksheet_write_string(worksheet, row + 1, 0, "*** Best Results File not found. Couldn't compare any result!", styles["summaryStyle"]); diff --git a/src/Platform/Results.cc b/src/Platform/Results.cc index d03f22e..51ecc87 100644 --- a/src/Platform/Results.cc +++ b/src/Platform/Results.cc @@ -3,7 +3,7 @@ #include "Results.h" #include "ReportConsole.h" #include "ReportExcel.h" -#include "BestResult.h" +#include "BestScore.h" #include "Colors.h" namespace platform { Result::Result(const string& path, const string& filename) @@ -17,8 +17,8 @@ namespace platform { score += result["score"].get(); } scoreName = data["score_name"]; - if (scoreName == BestResult::scoreName()) { - score /= BestResult::score(); + if (scoreName == BestScore::scoreName()) { + score /= BestScore::score(); } title = data["title"]; duration = data["duration"]; diff --git a/src/Platform/best.cc b/src/Platform/best.cc new file mode 100644 index 0000000..585cb17 --- /dev/null +++ b/src/Platform/best.cc @@ -0,0 +1,52 @@ +#include +#include +#include "platformUtils.h" +#include "Paths.h" +#include "Results.h" + +using namespace std; + +argparse::ArgumentParser manageArguments(int argc, char** argv) +{ + argparse::ArgumentParser program("best"); + program.add_argument("-n", "--number").default_value(0).help("Number of results to show (0 = all)").scan<'i', int>(); + program.add_argument("-m", "--model").default_value("any").help("Filter results of the selected model)"); + program.add_argument("-s", "--score").default_value("any").help("Filter results of the score name supplied"); + program.add_argument("--complete").help("Show only results with all datasets").default_value(false).implicit_value(true); + program.add_argument("--partial").help("Show only partial results").default_value(false).implicit_value(true); + program.add_argument("--compare").help("Compare with best results").default_value(false).implicit_value(true); + try { + program.parse_args(argc, argv); + auto number = program.get("number"); + if (number < 0) { + throw runtime_error("Number of results must be greater than or equal to 0"); + } + auto model = program.get("model"); + auto score = program.get("score"); + auto complete = program.get("complete"); + auto partial = program.get("partial"); + auto compare = program.get("compare"); + } + catch (const exception& err) { + cerr << err.what() << endl; + cerr << program; + exit(1); + } + return program; +} + +int main(int argc, char** argv) +{ + auto program = manageArguments(argc, argv); + auto number = program.get("number"); + auto model = program.get("model"); + auto score = program.get("score"); + auto complete = program.get("complete"); + auto partial = program.get("partial"); + auto compare = program.get("compare"); + if (complete) + partial = false; + auto results = platform::Results(platform::Paths::results(), number, model, score, complete, partial, compare); + results.manage(); + return 0; +}