Add nominal or index dataset name in tex output
This commit is contained in:
@@ -215,7 +215,7 @@ namespace platform {
|
||||
return table;
|
||||
}
|
||||
|
||||
void BestResults::printTableResults(std::vector<std::string> models, json table, bool tex)
|
||||
void BestResults::printTableResults(std::vector<std::string> models, json table, bool tex, bool index)
|
||||
{
|
||||
std::stringstream oss;
|
||||
oss << Colors::GREEN() << "Best results for " << score << " as of " << table.at("dateTable").get<std::string>() << std::endl;
|
||||
@@ -225,7 +225,7 @@ namespace platform {
|
||||
auto bestResultsTex = BestResultsTex();
|
||||
auto bestResultsMd = BestResultsMd();
|
||||
if (tex) {
|
||||
bestResultsTex.results_header(models, table.at("dateTable").get<std::string>());
|
||||
bestResultsTex.results_header(models, table.at("dateTable").get<std::string>(), index);
|
||||
bestResultsMd.results_header(models, table.at("dateTable").get<std::string>());
|
||||
}
|
||||
for (const auto& model : models) {
|
||||
@@ -242,7 +242,7 @@ namespace platform {
|
||||
int nDatasets = table.begin().value().size();
|
||||
auto datasets = getDatasets(table.begin().value());
|
||||
if (tex) {
|
||||
bestResultsTex.results_body(datasets, table);
|
||||
bestResultsTex.results_body(datasets, table, index);
|
||||
bestResultsMd.results_body(datasets, table);
|
||||
}
|
||||
for (auto const& dataset_ : datasets) {
|
||||
@@ -326,14 +326,14 @@ namespace platform {
|
||||
messageOutputFile("Excel", excel_report.getFileName());
|
||||
}
|
||||
}
|
||||
void BestResults::reportAll(bool excel, bool tex)
|
||||
void BestResults::reportAll(bool excel, bool tex, bool index)
|
||||
{
|
||||
auto models = getModels();
|
||||
// Build the table of results
|
||||
json table = buildTableResults(models);
|
||||
std::vector<std::string> datasets = getDatasets(table.begin().value());
|
||||
// Print the table of results
|
||||
printTableResults(models, table, tex);
|
||||
printTableResults(models, table, tex, index);
|
||||
// Compute the Friedman test
|
||||
std::map<std::string, std::map<std::string, float>> ranksModels;
|
||||
if (friedman) {
|
||||
|
@@ -13,7 +13,7 @@ namespace platform {
|
||||
}
|
||||
std::string build();
|
||||
void reportSingle(bool excel);
|
||||
void reportAll(bool excel, bool tex);
|
||||
void reportAll(bool excel, bool tex, bool index);
|
||||
void buildAll();
|
||||
private:
|
||||
std::vector<std::string> getModels();
|
||||
@@ -21,7 +21,7 @@ namespace platform {
|
||||
std::vector<std::string> loadResultFiles();
|
||||
void messageOutputFile(const std::string& title, const std::string& fileName);
|
||||
json buildTableResults(std::vector<std::string> models);
|
||||
void printTableResults(std::vector<std::string> models, json table, bool tex);
|
||||
void printTableResults(std::vector<std::string> models, json table, bool tex, bool index);
|
||||
json loadFile(const std::string& fileName);
|
||||
void listFile();
|
||||
std::string path;
|
||||
|
@@ -12,7 +12,7 @@ namespace platform {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
void BestResultsTex::results_header(const std::vector<std::string>& models, const std::string& date)
|
||||
void BestResultsTex::results_header(const std::vector<std::string>& models, const std::string& date, bool index)
|
||||
{
|
||||
this->models = models;
|
||||
auto file_name = Paths::tex() + Paths::tex_output();
|
||||
@@ -29,7 +29,8 @@ namespace platform {
|
||||
handler << "\\renewcommand{\\tabcolsep }{0.07cm} " << std::endl;
|
||||
handler << "\\caption{Accuracy results(mean $\\pm$ std) for all the algorithms and datasets} " << std::endl;
|
||||
handler << "\\label{tab:results_accuracy}" << std::endl;
|
||||
handler << "\\begin{tabular} {{r" << std::string(models.size(), 'c').c_str() << "}}" << std::endl;
|
||||
std::string header_dataset_name = index ? "r" : "l";
|
||||
handler << "\\begin{tabular} {{" << header_dataset_name << std::string(models.size(), 'c').c_str() << "}}" << std::endl;
|
||||
handler << "\\hline " << std::endl;
|
||||
handler << "" << std::endl;
|
||||
for (const auto& model : models) {
|
||||
@@ -38,13 +39,12 @@ namespace platform {
|
||||
handler << "\\\\" << std::endl;
|
||||
handler << "\\hline" << std::endl;
|
||||
}
|
||||
void BestResultsTex::results_body(const std::vector<std::string>& datasets, json& table)
|
||||
void BestResultsTex::results_body(const std::vector<std::string>& datasets, json& table, bool index)
|
||||
{
|
||||
int i = 0;
|
||||
for (auto const& dataset : datasets) {
|
||||
// Find out max value for this dataset
|
||||
double max_value = 0;
|
||||
// Find out the max value for this dataset
|
||||
for (const auto& model : models) {
|
||||
double value;
|
||||
try {
|
||||
@@ -57,7 +57,10 @@ namespace platform {
|
||||
max_value = value;
|
||||
}
|
||||
}
|
||||
handler << ++i << " ";
|
||||
if (index)
|
||||
handler << ++i << " ";
|
||||
else
|
||||
handler << dataset << " ";
|
||||
for (const auto& model : models) {
|
||||
double value = table[model].at(dataset).at(0).get<double>();
|
||||
double std_value = table[model].at(dataset).at(3).get<double>();
|
||||
|
@@ -9,13 +9,14 @@ namespace platform {
|
||||
using json = nlohmann::ordered_json;
|
||||
class BestResultsTex {
|
||||
public:
|
||||
BestResultsTex() = default;
|
||||
BestResultsTex(bool dataset_name = true) : dataset_name(dataset_name) {};
|
||||
~BestResultsTex() = default;
|
||||
void results_header(const std::vector<std::string>& models, const std::string& date);
|
||||
void results_body(const std::vector<std::string>& datasets, json& table);
|
||||
void results_header(const std::vector<std::string>& models, const std::string& date, bool index);
|
||||
void results_body(const std::vector<std::string>& datasets, json& table, bool index);
|
||||
void results_footer(const std::map<std::string, std::vector<double>>& totals, const std::string& best_model);
|
||||
void holm_test(struct HolmResult& holmResult, const std::string& date);
|
||||
private:
|
||||
bool dataset_name;
|
||||
void openTexFile(const std::string& name);
|
||||
std::ofstream handler;
|
||||
std::vector<std::string> models;
|
||||
|
Reference in New Issue
Block a user