Add best results Excel
This commit is contained in:
parent
85202260f3
commit
cfcf3c16df
@ -301,7 +301,7 @@ namespace platform {
|
|||||||
stats.postHocHolmTest(result);
|
stats.postHocHolmTest(result);
|
||||||
}
|
}
|
||||||
if (excel) {
|
if (excel) {
|
||||||
BestResultsExcel excel(models, datasets, table, friedman);
|
BestResultsExcel excel(score, models, datasets, table, friedman);
|
||||||
excel.build();
|
excel.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,35 @@
|
|||||||
|
#include <sstream>
|
||||||
#include "BestResultsExcel.h"
|
#include "BestResultsExcel.h"
|
||||||
#include "Paths.h"
|
#include "Paths.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
BestResultsExcel::BestResultsExcel(vector<string> models, vector<string> datasets, json table, bool friedman) : models(models), datasets(datasets), table(table), friedman(friedman)
|
BestResultsExcel::BestResultsExcel(string score, vector<string> models, vector<string> datasets, json table, bool friedman) : score(score), models(models), datasets(datasets), table(table), friedman(friedman)
|
||||||
{
|
{
|
||||||
workbook = workbook_new((Paths::excel() + fileName).c_str());
|
workbook = workbook_new((Paths::excel() + fileName).c_str());
|
||||||
worksheet = workbook_add_worksheet(workbook, "Best Results");
|
worksheet = workbook_add_worksheet(workbook, "Best Results");
|
||||||
setProperties("Best Results");
|
setProperties("Best Results");
|
||||||
createFormats();
|
createFormats();
|
||||||
|
int maxModelName = (*max_element(models.begin(), models.end(), [](const string& a, const string& b) { return a.size() < b.size(); })).size();
|
||||||
|
modelNameSize = max(modelNameSize, maxModelName);
|
||||||
|
int maxDatasetName = (*max_element(datasets.begin(), datasets.end(), [](const string& a, const string& b) { return a.size() < b.size(); })).size();
|
||||||
|
datasetNameSize = max(datasetNameSize, maxDatasetName);
|
||||||
formatColumns();
|
formatColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
BestResultsExcel::~BestResultsExcel()
|
BestResultsExcel::~BestResultsExcel()
|
||||||
{
|
{
|
||||||
workbook_close(workbook);
|
workbook_close(workbook);
|
||||||
}
|
}
|
||||||
void BestResultsExcel::formatColumns()
|
void BestResultsExcel::formatColumns()
|
||||||
{
|
{
|
||||||
|
worksheet_freeze_panes(worksheet, 4, 2);
|
||||||
|
vector<int> columns_sizes = { 5, datasetNameSize };
|
||||||
|
for (int i = 0; i < models.size(); ++i) {
|
||||||
|
columns_sizes.push_back(modelNameSize);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < columns_sizes.size(); ++i) {
|
||||||
|
worksheet_set_column(worksheet, i, i, columns_sizes.at(i), NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void BestResultsExcel::build()
|
void BestResultsExcel::build()
|
||||||
{
|
{
|
||||||
@ -27,15 +39,47 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
void BestResultsExcel::header()
|
void BestResultsExcel::header()
|
||||||
{
|
{
|
||||||
|
row = 0;
|
||||||
|
string message = "Best results for " + score;
|
||||||
|
worksheet_merge_range(worksheet, 0, 0, 0, 1 + models.size(), message.c_str(), styles["headerFirst"]);
|
||||||
|
|
||||||
|
// Body header
|
||||||
|
row = 3;
|
||||||
|
int col = 1;
|
||||||
|
writeString(row, 0, "Nº", "bodyHeader");
|
||||||
|
writeString(row, 1, "Dataset", "bodyHeader");
|
||||||
|
for (const auto& model : models) {
|
||||||
|
writeString(row, ++col, model.c_str(), "bodyHeader");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void BestResultsExcel::body()
|
void BestResultsExcel::body()
|
||||||
{
|
{
|
||||||
|
row = 4;
|
||||||
|
int i = 0;
|
||||||
|
json origin = table.begin().value();
|
||||||
|
for (auto const& item : origin.items()) {
|
||||||
|
writeInt(row, 0, i++, "ints");
|
||||||
|
writeString(row, 1, item.key().c_str(), "text");
|
||||||
|
int col = 1;
|
||||||
|
for (const auto& model : models) {
|
||||||
|
double value = table[model].at(item.key()).at(0).get<double>();
|
||||||
|
writeDouble(row, ++col, value, "result");
|
||||||
|
}
|
||||||
|
++row;
|
||||||
|
}
|
||||||
|
// Set Totals
|
||||||
|
writeString(row, 1, "Total", "bodyHeader");
|
||||||
|
int col = 1;
|
||||||
|
for (const auto& model : models) {
|
||||||
|
stringstream oss;
|
||||||
|
oss << "=sum(indirect(address(" << 5 << "," << col + 2 << ")):indirect(address(" << row << "," << col + 2 << ")))";
|
||||||
|
worksheet_write_formula(worksheet, row, ++col, oss.str().c_str(), styles["bodyHeader_odd"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void BestResultsExcel::footer()
|
void BestResultsExcel::footer()
|
||||||
{
|
{
|
||||||
|
if (friedman) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ using json = nlohmann::json;
|
|||||||
namespace platform {
|
namespace platform {
|
||||||
class BestResultsExcel : ExcelFile {
|
class BestResultsExcel : ExcelFile {
|
||||||
public:
|
public:
|
||||||
BestResultsExcel(vector<string> models, vector<string> datasets, json table, bool friedman);
|
BestResultsExcel(string score, vector<string> models, vector<string> datasets, json table, bool friedman);
|
||||||
~BestResultsExcel();
|
~BestResultsExcel();
|
||||||
void build();
|
void build();
|
||||||
private:
|
private:
|
||||||
@ -19,11 +19,13 @@ namespace platform {
|
|||||||
void footer();
|
void footer();
|
||||||
void formatColumns();
|
void formatColumns();
|
||||||
const string fileName = "BestResults.xlsx";
|
const string fileName = "BestResults.xlsx";
|
||||||
|
string score;
|
||||||
vector<string> models;
|
vector<string> models;
|
||||||
vector<string> datasets;
|
vector<string> datasets;
|
||||||
json table;
|
json table;
|
||||||
bool friedman;
|
bool friedman;
|
||||||
|
int modelNameSize = 12; // Min size of the column
|
||||||
|
int datasetNameSize = 25; // Min size of the column
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif //BESTRESULTS_EXCEL_H
|
#endif //BESTRESULTS_EXCEL_H
|
@ -1,11 +1,19 @@
|
|||||||
#ifndef EXCELFILE_H
|
#ifndef EXCELFILE_H
|
||||||
#define EXCELFILE_H
|
#define EXCELFILE_H
|
||||||
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "xlsxwriter.h"
|
#include "xlsxwriter.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
namespace platform {
|
namespace platform {
|
||||||
|
struct separated : numpunct<char> {
|
||||||
|
char do_decimal_point() const { return ','; }
|
||||||
|
|
||||||
|
char do_thousands_sep() const { return '.'; }
|
||||||
|
|
||||||
|
string do_grouping() const { return "\03"; }
|
||||||
|
};
|
||||||
class ExcelFile {
|
class ExcelFile {
|
||||||
public:
|
public:
|
||||||
ExcelFile();
|
ExcelFile();
|
||||||
|
@ -5,13 +5,6 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
struct separated : numpunct<char> {
|
|
||||||
char do_decimal_point() const { return ','; }
|
|
||||||
|
|
||||||
char do_thousands_sep() const { return '.'; }
|
|
||||||
|
|
||||||
string do_grouping() const { return "\03"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
ReportExcel::ReportExcel(json data_, bool compare, lxw_workbook* workbook) : ReportBase(data_, compare), ExcelFile(workbook)
|
ReportExcel::ReportExcel(json data_, bool compare, lxw_workbook* workbook) : ReportBase(data_, compare), ExcelFile(workbook)
|
||||||
{
|
{
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
#include "Colors.h"
|
#include "Colors.h"
|
||||||
namespace platform {
|
namespace platform {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
const int MAXLL = 128;
|
|
||||||
|
|
||||||
class ReportExcel : public ReportBase, public ExcelFile {
|
class ReportExcel : public ReportBase, public ExcelFile {
|
||||||
public:
|
public:
|
||||||
explicit ReportExcel(json data_, bool compare, lxw_workbook* workbook);
|
explicit ReportExcel(json data_, bool compare, lxw_workbook* workbook);
|
||||||
|
Loading…
Reference in New Issue
Block a user