Adjust filename and hyperparameters in reports

This commit is contained in:
Ricardo Montañana Gómez 2023-10-20 11:12:46 +02:00
parent 38423048bd
commit 04e754b2f5
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE
4 changed files with 17 additions and 20 deletions

View File

@ -3,6 +3,7 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <algorithm>
#include "BestResults.h"
#include "Result.h"
#include "Colors.h"
@ -155,12 +156,19 @@ namespace platform {
auto data = loadFile(bestFileName);
auto datasets = getDatasets(data);
int maxDatasetName = (*max_element(datasets.begin(), datasets.end(), [](const string& a, const string& b) { return a.size() < b.size(); })).size();
int maxFileName = 0;
int maxHyper = 0;
for (auto const& item : data.items()) {
maxHyper = max(maxHyper, (int)item.value().at(1).dump().size());
maxFileName = max(maxFileName, (int)item.value().at(2).get<string>().size());
}
cout << "Hola" << endl;
stringstream oss;
oss << Colors::GREEN() << "Best results for " << model << " as of " << date << endl;
cout << oss.str();
cout << string(oss.str().size() - 8, '-') << endl;
cout << Colors::GREEN() << " # " << setw(maxDatasetName + 1) << left << string("Dataset") << "Score File Hyperparameters" << endl;
cout << "=== " << string(maxDatasetName, '=') << " =========== ================================================================== ================================================= " << endl;
cout << "=== " << string(maxDatasetName, '=') << " =========== " << string(maxFileName, '=') << " " << string(maxHyper, '=') << endl;
auto i = 0;
bool odd = true;
double total = 0;
@ -170,7 +178,7 @@ namespace platform {
cout << color << setw(3) << fixed << right << i++ << " ";
cout << setw(maxDatasetName) << left << item.key() << " ";
cout << setw(11) << setprecision(9) << fixed << value << " ";
cout << setw(66) << item.value().at(2).get<string>() << " ";
cout << setw(maxFileName) << item.value().at(2).get<string>() << " ";
cout << item.value().at(1) << " ";
cout << endl;
total += value;

View File

@ -60,14 +60,7 @@ namespace platform {
writeString(row, 1, item.key().c_str(), "text");
writeDouble(row, 2, item.value().at(0).get<double>(), "result");
writeString(row, 3, item.value().at(2).get<string>(), "text");
try {
hyperparameters = item.value().at(1).get<string>();
}
catch (const exception& err) {
stringstream oss;
oss << item.value().at(1);
hyperparameters = oss.str();
}
hyperparameters = item.value().at(1).dump();
if (hyperparameters.size() > hypSize) {
hypSize = hyperparameters.size();
}

View File

@ -28,8 +28,12 @@ namespace platform {
void ReportConsole::body()
{
auto tmp = ConfigLocale();
int maxHyper = 0;
for (const auto& r : data["results"]) {
maxHyper = max(maxHyper, (int)r["hyperparameters"].dump().size());
}
cout << Colors::GREEN() << " # Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl;
cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== ====================" << endl;
cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== " << string(maxHyper, '=') << endl;
json lastResult;
double totalScore = 0.0;
bool odd = true;

View File

@ -115,14 +115,7 @@ namespace platform {
writeString(row, col + 9, status, "textCentered");
writeDouble(row, col + 10, r["time"].get<double>(), "time");
writeDouble(row, col + 11, r["time_std"].get<double>(), "time");
try {
hyperparameters = r["hyperparameters"].get<string>();
}
catch (const exception& err) {
stringstream oss;
oss << r["hyperparameters"];
hyperparameters = oss.str();
}
hyperparameters = r["hyperparameters"].dump();
if (hyperparameters.size() > hypSize) {
hypSize = hyperparameters.size();
}
@ -130,7 +123,6 @@ namespace platform {
lastResult = r;
totalScore += r["score"].get<double>();
row++;
}
// Set the right column width of hyperparameters with the maximum length
worksheet_set_column(worksheet, 12, 12, hypSize + 5, NULL);