Add variable width of dataset name in reports

This commit is contained in:
Ricardo Montañana Gómez 2023-10-22 22:58:52 +02:00
parent 833acefbb3
commit 7bcd2eed06
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE
4 changed files with 14 additions and 10 deletions

View File

@ -46,13 +46,14 @@ namespace platform {
cout << Colors::MAGENTA() << "Only listing partial results" << endl;
}
auto i = 0;
cout << Colors::GREEN() << " # Date Model Score Name Score C/P Duration Title" << endl;
cout << "=== ========== ============ =========== =========== === ========= =============================================================" << endl;
int maxModel = results.maxModelSize();
cout << Colors::GREEN() << " # Date " << setw(maxModel) << left << "Model" << " Score Name Score C / P Duration Title" << endl;
cout << "=== ========== " << string(maxModel, '=') << " =========== =========== === ========= =============================================================" << endl;
bool odd = true;
for (auto& result : results) {
auto color = odd ? Colors::BLUE() : Colors::CYAN();
cout << color << setw(3) << fixed << right << i++ << " ";
cout << result.to_string() << endl;
cout << result.to_string(maxModel) << endl;
if (i == numFiles) {
break;
}

View File

@ -29,11 +29,14 @@ namespace platform {
{
auto tmp = ConfigLocale();
int maxHyper = 0;
int maxDataset = 0;
for (const auto& r : data["results"]) {
maxHyper = max(maxHyper, (int)r["hyperparameters"].dump().size());
maxDataset = max(maxDataset, (int)r["dataset"].get<string>().size());
}
cout << Colors::GREEN() << " # Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl;
cout << "=== ========================= ====== ===== === ========= ========= ========= =============== =================== " << string(maxHyper, '=') << endl;
cout << Colors::GREEN() << " # " << setw(maxDataset) << left << "Dataset" << " Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl;
cout << "=== " << string(maxDataset, '=') << " ====== ===== === ========= ========= ========= =============== =================== " << string(maxHyper, '=') << endl;
json lastResult;
double totalScore = 0.0;
bool odd = true;
@ -45,8 +48,8 @@ namespace platform {
}
auto color = odd ? Colors::CYAN() : Colors::BLUE();
cout << color;
cout << setw(3) << index++ << " ";
cout << setw(25) << left << r["dataset"].get<string>() << " ";
cout << setw(3) << right << index++ << " ";
cout << setw(maxDataset) << left << r["dataset"].get<string>() << " ";
cout << setw(6) << right << r["samples"].get<int>() << " ";
cout << setw(5) << right << r["features"].get<int>() << " ";
cout << setw(3) << right << r["classes"].get<int>() << " ";

View File

@ -37,14 +37,14 @@ namespace platform {
throw invalid_argument("Unable to open result file. [" + path + "/" + filename + "]");
}
string Result::to_string() const
string Result::to_string(int maxModel) const
{
auto tmp = ConfigLocale();
stringstream oss;
double durationShow = duration > 3600 ? duration / 3600 : duration > 60 ? duration / 60 : duration;
string durationUnit = duration > 3600 ? "h" : duration > 60 ? "m" : "s";
oss << date << " ";
oss << setw(12) << left << model << " ";
oss << setw(maxModel) << left << model << " ";
oss << setw(11) << left << scoreName << " ";
oss << right << setw(11) << setprecision(7) << fixed << score << " ";
auto completeString = isComplete() ? "C" : "P";

View File

@ -12,7 +12,7 @@ namespace platform {
public:
Result(const string& path, const string& filename);
json load() const;
string to_string() const;
string to_string(int maxModel) const;
string getFilename() const { return filename; };
string getDate() const { return date; };
double getScore() const { return score; };