Add format to unique dataset results summary

This commit is contained in:
Ricardo Montañana Gómez 2023-09-20 10:30:45 +02:00
parent c280e254ca
commit b9bc0088f3
Signed by: rmontanana
GPG Key ID: 46064262FD9A7ADE

View File

@ -180,20 +180,22 @@ namespace platform {
} }
const string name = data["model"].get<string>(); const string name = data["model"].get<string>();
string suffix = ""; string suffix = "";
string efectiveName;
int num = 1; int num = 1;
// Create a sheet with the name of the model // Create a sheet with the name of the model
while (true) { while (true) {
string efectiveName = name + suffix; efectiveName = name + suffix;
worksheet = workbook_add_worksheet(workbook, efectiveName.c_str()); if (workbook_get_worksheet_by_name(workbook, efectiveName.c_str())) {
if (worksheet == NULL) {
suffix = to_string(++num); suffix = to_string(++num);
} else { } else {
worksheet = workbook_add_worksheet(workbook, efectiveName.c_str());
break; break;
} }
if (num > 100) { if (num > 100) {
throw invalid_argument("Couldn't create sheet " + efectiveName); throw invalid_argument("Couldn't create sheet " + efectiveName);
} }
} }
cout << "Adding sheet " << efectiveName << " to " << Paths::excel() + fileName << endl;
setProperties(); setProperties();
createFormats(); createFormats();
formatColumns(); formatColumns();
@ -284,17 +286,24 @@ namespace platform {
} }
// Set the right column width of hyperparameters with the maximum length // Set the right column width of hyperparameters with the maximum length
worksheet_set_column(worksheet, 12, 12, hypSize + 1, NULL); worksheet_set_column(worksheet, 12, 12, hypSize + 5, NULL);
// Show totals if only one dataset is present in the result // Show totals if only one dataset is present in the result
if (data["results"].size() == 1) { if (data["results"].size() == 1) {
for (const string& group : { "scores_train", "scores_test", "times_train", "times_test" }) { for (const string& group : { "scores_train", "scores_test", "times_train", "times_test" }) {
row++; row++;
col = 1; col = 1;
writeString(row, col, group); writeString(row, col, group, "text");
for (double item : lastResult[group]) { for (double item : lastResult[group]) {
writeDouble(row, ++col, item); string style = group.find("scores") != string::npos ? "result" : "time";
writeDouble(row, ++col, item, style);
} }
} }
// Set with of columns to show those totals completely
worksheet_set_column(worksheet, 1, 1, 12, NULL);
for (int i = 2; i < 7; ++i) {
// doesn't work with from col to col, so...
worksheet_set_column(worksheet, i, i, 15, NULL);
}
} else { } else {
footer(totalScore, row); footer(totalScore, row);
} }