diff --git a/src/best/BestResults.cpp b/src/best/BestResults.cpp index 5e7c349..4cffc84 100644 --- a/src/best/BestResults.cpp +++ b/src/best/BestResults.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "common/Colors.h" #include "common/CLocale.h" #include "common/Paths.h" @@ -123,16 +124,24 @@ namespace platform { } result = std::vector(models.begin(), models.end()); maxModelName = (*max_element(result.begin(), result.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); })).size(); - maxModelName = std::max(12, maxModelName); + maxModelName = std::max(minLength, maxModelName); return result; } + std::string toLower(std::string data) + { + std::transform(data.begin(), data.end(), data.begin(), + [](unsigned char c) { return std::tolower(c); }); + return data; + } std::vector BestResults::getDatasets(json table) { std::vector datasets; for (const auto& dataset_ : table.items()) { datasets.push_back(dataset_.key()); } - std::stable_sort(datasets.begin(), datasets.end()); + std::stable_sort(datasets.begin(), datasets.end(), [](const std::string& a, const std::string& b) { + return toLower(a) < toLower(b); + }); maxDatasetName = (*max_element(datasets.begin(), datasets.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); })).size(); maxDatasetName = std::max(7, maxDatasetName); return datasets; @@ -266,12 +275,14 @@ namespace platform { // Print the row with red colors on max values for (const auto& model : models) { std::string efectiveColor = color; - double value; + double value, std; try { value = table[model].at(dataset_).at(0).get(); + std = table[model].at(dataset_).at(3).get(); } catch (nlohmann::json_abi_v3_11_3::detail::out_of_range err) { value = -1.0; + std = -1.0; } if (value == maxValue) { efectiveColor = Colors::RED(); @@ -280,7 +291,8 @@ namespace platform { std::cout << Colors::YELLOW() << std::setw(maxModelName) << std::right << "N/A" << " "; } else { totals[model].push_back(value); - std::cout << efectiveColor << std::setw(maxModelName) << std::setprecision(maxModelName - 2) << std::fixed << value << " "; + std::cout << efectiveColor << std::setw(maxModelName - 6) << std::setprecision(maxModelName - 8) << std::fixed << value; + std::cout << efectiveColor << "±" << std::setw(5) << std::setprecision(3) << std::fixed << std << " "; } } std::cout << std::endl; @@ -307,9 +319,9 @@ namespace platform { for (const auto& model : models) { std::string efectiveColor = model == best_model ? Colors::RED() : Colors::GREEN(); double value = std::reduce(totals[model].begin(), totals[model].end()) / nDatasets; - double std_value = compute_std(totals[model], value); - std::cout << efectiveColor << std::right << std::setw(maxModelName) << std::setprecision(maxModelName - 4) << std::fixed << value << " "; - + double std = compute_std(totals[model], value); + std::cout << efectiveColor << std::right << std::setw(maxModelName - 6) << std::setprecision(maxModelName - 8) << std::fixed << value; + std::cout << efectiveColor << "±" << std::setw(5) << std::setprecision(3) << std::fixed << std << " "; } std::cout << std::endl; } diff --git a/src/best/BestResults.h b/src/best/BestResults.h index fde6a74..4d3c307 100644 --- a/src/best/BestResults.h +++ b/src/best/BestResults.h @@ -32,6 +32,7 @@ namespace platform { double significance; int maxModelName = 0; int maxDatasetName = 0; + int minLength = 13; // Minimum length for scores }; } #endif \ No newline at end of file diff --git a/src/commands/b_best.cpp b/src/commands/b_best.cpp index fb4b5cd..aaefbec 100644 --- a/src/commands/b_best.cpp +++ b/src/commands/b_best.cpp @@ -5,14 +5,16 @@ #include "common/Paths.h" #include "common/Colors.h" #include "best/BestResults.h" +#include "common/DotEnv.h" #include "config_platform.h" void manageArguments(argparse::ArgumentParser& program) { + auto env = platform::DotEnv(); program.add_argument("-m", "--model").help("Model to use or any").default_value("any"); program.add_argument("--folder").help("Results folder to use").default_value(platform::Paths::results()); program.add_argument("-d", "--dataset").default_value("any").help("Filter results of the selected model) (any for all datasets)"); - program.add_argument("-s", "--score").default_value("accuracy").help("Filter results of the score name supplied"); + program.add_argument("-s", "--score").default_value(env.get("score")).help("Filter results of the score name supplied"); program.add_argument("--friedman").help("Friedman test").default_value(false).implicit_value(true); program.add_argument("--excel").help("Output to excel").default_value(false).implicit_value(true); program.add_argument("--tex").help("Output results to TeX & Markdown files").default_value(false).implicit_value(true); diff --git a/src/main/ArgumentsExperiment.cpp b/src/main/ArgumentsExperiment.cpp index 58bf990..d27f9a3 100644 --- a/src/main/ArgumentsExperiment.cpp +++ b/src/main/ArgumentsExperiment.cpp @@ -221,7 +221,8 @@ namespace platform { std::array buffer; // Run g++ --version and capture the output - std::unique_ptr pipe(popen("g++ --version", "r"), pclose); + using pclose_t = int(*)(FILE*); + std::unique_ptr pipe(popen("g++ --version", "r"), pclose); if (!pipe) { return "Error executing g++ --version command";