Add color and fix format in classification report in excel
This commit is contained in:
Submodule lib/libxlsxwriter updated: 26c4c20bab...284b61ba0b
@@ -75,7 +75,7 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
void ExcelFile::boldGreen()
|
void ExcelFile::boldGreen()
|
||||||
{
|
{
|
||||||
boldFontColor(0x00FF00);
|
boldFontColor(0x009900);
|
||||||
}
|
}
|
||||||
void ExcelFile::boldRed()
|
void ExcelFile::boldRed()
|
||||||
{
|
{
|
||||||
|
@@ -215,8 +215,7 @@ namespace platform {
|
|||||||
if (matrix_sheet == NULL) {
|
if (matrix_sheet == NULL) {
|
||||||
throw std::invalid_argument("Couldn't create sheet classif_report");
|
throw std::invalid_argument("Couldn't create sheet classif_report");
|
||||||
}
|
}
|
||||||
worksheet_merge_range(matrix_sheet, 0, 0, 0, 5, "Classification Report", efectiveStyle("bodyHeader"));
|
row = 1;
|
||||||
int row = 2;
|
|
||||||
int col = 0;
|
int col = 0;
|
||||||
if (result.find("confusion_matrices_train") != result.end()) {
|
if (result.find("confusion_matrices_train") != result.end()) {
|
||||||
// Train classification report
|
// Train classification report
|
||||||
@@ -229,11 +228,14 @@ namespace platform {
|
|||||||
auto item = result["confusion_matrices_train"][i];
|
auto item = result["confusion_matrices_train"][i];
|
||||||
auto score_item = Scores(item);
|
auto score_item = Scores(item);
|
||||||
auto title = "Train Fold " + std::to_string(i);
|
auto title = "Train Fold " + std::to_string(i);
|
||||||
std::tie(new_row, new_col) = write_classification_report(score_item.classification_report_json(title), 2, new_col);
|
std::tie(new_row, new_col) = write_classification_report(score_item.classification_report_json(title), 1, new_col);
|
||||||
new_col++;
|
new_col++;
|
||||||
}
|
}
|
||||||
|
col = new_col;
|
||||||
|
worksheet_merge_range(matrix_sheet, 0, 0, 0, col - 1, "Train Classification Report", efectiveStyle("headerRest"));
|
||||||
}
|
}
|
||||||
// Test classification report
|
// Test classification report
|
||||||
|
worksheet_merge_range(matrix_sheet, row, 0, row, col - 1, "Test Classification Report", efectiveStyle("headerRest"));
|
||||||
auto score = Scores::create_aggregate(result, "confusion_matrices");
|
auto score = Scores::create_aggregate(result, "confusion_matrices");
|
||||||
auto test = score.classification_report_json("Test");
|
auto test = score.classification_report_json("Test");
|
||||||
int init_row = ++row;
|
int init_row = ++row;
|
||||||
@@ -256,9 +258,10 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
std::pair<int, int> ReportExcel::write_classification_report(const json& result, int init_row, int init_col)
|
std::pair<int, int> ReportExcel::write_classification_report(const json& result, int init_row, int init_col)
|
||||||
{
|
{
|
||||||
int row = init_row;
|
row = init_row;
|
||||||
auto text = result["title"].get<std::string>();
|
auto text = result["title"].get<std::string>();
|
||||||
worksheet_merge_range(worksheet, row++, init_col, row, init_col + 5, text.c_str(), efectiveStyle("bodyHeader"));
|
worksheet_merge_range(worksheet, row, init_col, row + 1, init_col + 5, text.c_str(), efectiveStyle("bodyHeader"));
|
||||||
|
row += 2;
|
||||||
int col = init_col + 2;
|
int col = init_col + 2;
|
||||||
// Headers
|
// Headers
|
||||||
bool first_item = true;
|
bool first_item = true;
|
||||||
@@ -288,8 +291,6 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
worksheet_merge_range(worksheet, row, init_col, row, init_col + 5, "", efectiveStyle("text"));
|
|
||||||
row++;
|
|
||||||
// Accuracy and average f1-score
|
// Accuracy and average f1-score
|
||||||
for (const auto& item : { "accuracy", "averages", "weighted" }) {
|
for (const auto& item : { "accuracy", "averages", "weighted" }) {
|
||||||
col = init_col + 2;
|
col = init_col + 2;
|
||||||
@@ -307,11 +308,10 @@ namespace platform {
|
|||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
// Confusion matrix
|
// Confusion matrix
|
||||||
worksheet_merge_range(worksheet, row, init_col, row, init_col + 5, "", efectiveStyle("bodyHeader"));
|
|
||||||
row++;
|
|
||||||
auto n_items = result["confusion_matrix"].size();
|
auto n_items = result["confusion_matrix"].size();
|
||||||
worksheet_merge_range(worksheet, row, init_col, row, init_col + n_items + 1, "Confusion Matrix", efectiveStyle("bodyHeader"));
|
worksheet_merge_range(worksheet, row, init_col, row, init_col + n_items + 1, "Confusion Matrix", efectiveStyle("bodyHeader"));
|
||||||
row++;
|
row++;
|
||||||
|
boldGreen();
|
||||||
for (int i = 0; i < n_items; ++i) {
|
for (int i = 0; i < n_items; ++i) {
|
||||||
col = init_col + 2;
|
col = init_col + 2;
|
||||||
auto label = result["body"][i][0].get<std::string>();
|
auto label = result["body"][i][0].get<std::string>();
|
||||||
@@ -326,7 +326,7 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
int maxcol = std::max(5, int(init_col + n_items + 1));
|
int maxcol = std::max(init_col + 5, int(init_col + n_items + 1));
|
||||||
return { row, maxcol };
|
return { row, maxcol };
|
||||||
}
|
}
|
||||||
void ReportExcel::showSummary()
|
void ReportExcel::showSummary()
|
||||||
|
Reference in New Issue
Block a user