Add enhanced notes info and add notes to excel
This commit is contained in:
@@ -217,7 +217,8 @@ namespace platform {
|
|||||||
if (!quiet)
|
if (!quiet)
|
||||||
showProgress(nfold + 1, getColor(clf->getStatus()), "b");
|
showProgress(nfold + 1, getColor(clf->getStatus()), "b");
|
||||||
auto clf_notes = clf->getNotes();
|
auto clf_notes = clf->getNotes();
|
||||||
notes.insert(notes.end(), clf_notes.begin(), clf_notes.end());
|
std::transform(clf_notes.begin(), clf_notes.end(), std::back_inserter(notes), [nfold](const std::string& note)
|
||||||
|
{ return "Fold " + std::to_string(nfold) + ": " + note; });
|
||||||
nodes[item] = clf->getNumberOfNodes();
|
nodes[item] = clf->getNumberOfNodes();
|
||||||
edges[item] = clf->getNumberOfEdges();
|
edges[item] = clf->getNumberOfEdges();
|
||||||
num_states[item] = clf->getNumberOfStates();
|
num_states[item] = clf->getNumberOfStates();
|
||||||
|
@@ -90,6 +90,25 @@ namespace platform {
|
|||||||
oss << "Discretized: " << (data["discretized"].get<bool>() ? "True" : "False");
|
oss << "Discretized: " << (data["discretized"].get<bool>() ? "True" : "False");
|
||||||
worksheet_write_string(worksheet, 3, 12, oss.str().c_str(), styles["headerSmall"]);
|
worksheet_write_string(worksheet, 3, 12, oss.str().c_str(), styles["headerSmall"]);
|
||||||
}
|
}
|
||||||
|
void ReportExcel::append_notes(lxw_worksheet* notes_worksheet, const json& r, int row)
|
||||||
|
{
|
||||||
|
static bool even_note = true;
|
||||||
|
std::string suffix;
|
||||||
|
if (even_note) {
|
||||||
|
even_note = false;
|
||||||
|
suffix = "_even";
|
||||||
|
} else {
|
||||||
|
even_note = true;
|
||||||
|
suffix = "_odd";
|
||||||
|
}
|
||||||
|
lxw_format* style = NULL;
|
||||||
|
style = styles.at("text" + suffix);
|
||||||
|
worksheet_merge_range(notes_worksheet, row, 0, row, 1, r["dataset"].get<std::string>().c_str(), style);
|
||||||
|
for (const auto& note : r["notes"]) {
|
||||||
|
worksheet_merge_range(notes_worksheet, row, 2, row, 8, note.get<std::string>().c_str(), style);
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReportExcel::body()
|
void ReportExcel::body()
|
||||||
{
|
{
|
||||||
@@ -106,6 +125,10 @@ namespace platform {
|
|||||||
json lastResult;
|
json lastResult;
|
||||||
double totalScore = 0.0;
|
double totalScore = 0.0;
|
||||||
std::string hyperparameters;
|
std::string hyperparameters;
|
||||||
|
bool only_one_result = data["results"].size() == 1;
|
||||||
|
bool first_note = true;
|
||||||
|
lxw_worksheet* notes_worksheet;
|
||||||
|
int notes_row = 0;
|
||||||
for (const auto& r : data["results"]) {
|
for (const auto& r : data["results"]) {
|
||||||
writeString(row, col, r["dataset"].get<std::string>(), "text");
|
writeString(row, col, r["dataset"].get<std::string>(), "text");
|
||||||
writeInt(row, col + 1, r["samples"].get<int>(), "ints");
|
writeInt(row, col + 1, r["samples"].get<int>(), "ints");
|
||||||
@@ -128,11 +151,24 @@ namespace platform {
|
|||||||
lastResult = r;
|
lastResult = r;
|
||||||
totalScore += r["score"].get<double>();
|
totalScore += r["score"].get<double>();
|
||||||
row++;
|
row++;
|
||||||
|
if (!only_one_result) {
|
||||||
|
// take care of the possible notes
|
||||||
|
if (r.find("notes") != r.end()) {
|
||||||
|
if (r["notes"].size() > 0) {
|
||||||
|
if (first_note) {
|
||||||
|
first_note = false;
|
||||||
|
notes_worksheet = workbook_add_worksheet(workbook, "Notes");
|
||||||
|
}
|
||||||
|
append_notes(notes_worksheet, r, notes_row);
|
||||||
|
notes_row += r["notes"].size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 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 + 5, 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 (only_one_result) {
|
||||||
row++;
|
row++;
|
||||||
if (lastResult.find("notes") != lastResult.end()) {
|
if (lastResult.find("notes") != lastResult.end()) {
|
||||||
if (lastResult["notes"].size() > 0) {
|
if (lastResult["notes"].size() > 0) {
|
||||||
|
@@ -18,7 +18,7 @@ namespace platform {
|
|||||||
void body() override;
|
void body() override;
|
||||||
void showSummary() override;
|
void showSummary() override;
|
||||||
void footer(double totalScore, int row);
|
void footer(double totalScore, int row);
|
||||||
|
void append_notes(lxw_worksheet* notes_worksheet, const json& r, int row);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#endif // !REPORTEXCEL_H
|
#endif // !REPORTEXCEL_H
|
Reference in New Issue
Block a user