ADd std to screen output

This commit is contained in:
2025-05-28 10:53:29 +02:00
parent a6b6efce95
commit dcde8c01be
4 changed files with 25 additions and 9 deletions

View File

@@ -4,6 +4,7 @@
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cctype>
#include "common/Colors.h"
#include "common/CLocale.h"
#include "common/Paths.h"
@@ -123,16 +124,24 @@ namespace platform {
}
result = std::vector<std::string>(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<std::string> BestResults::getDatasets(json table)
{
std::vector<std::string> 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<double>();
std = table[model].at(dataset_).at(3).get<double>();
}
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;
}

View File

@@ -32,6 +32,7 @@ namespace platform {
double significance;
int maxModelName = 0;
int maxDatasetName = 0;
int minLength = 13; // Minimum length for scores
};
}
#endif

View File

@@ -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);

View File

@@ -221,7 +221,8 @@ namespace platform {
std::array<char, 128> buffer;
// Run g++ --version and capture the output
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen("g++ --version", "r"), pclose);
using pclose_t = int(*)(FILE*);
std::unique_ptr<FILE, pclose_t> pipe(popen("g++ --version", "r"), pclose);
if (!pipe) {
return "Error executing g++ --version command";