Add nominal or index dataset name in tex output
This commit is contained in:
@@ -215,7 +215,7 @@ namespace platform {
|
|||||||
return table;
|
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;
|
std::stringstream oss;
|
||||||
oss << Colors::GREEN() << "Best results for " << score << " as of " << table.at("dateTable").get<std::string>() << std::endl;
|
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 bestResultsTex = BestResultsTex();
|
||||||
auto bestResultsMd = BestResultsMd();
|
auto bestResultsMd = BestResultsMd();
|
||||||
if (tex) {
|
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>());
|
bestResultsMd.results_header(models, table.at("dateTable").get<std::string>());
|
||||||
}
|
}
|
||||||
for (const auto& model : models) {
|
for (const auto& model : models) {
|
||||||
@@ -242,7 +242,7 @@ namespace platform {
|
|||||||
int nDatasets = table.begin().value().size();
|
int nDatasets = table.begin().value().size();
|
||||||
auto datasets = getDatasets(table.begin().value());
|
auto datasets = getDatasets(table.begin().value());
|
||||||
if (tex) {
|
if (tex) {
|
||||||
bestResultsTex.results_body(datasets, table);
|
bestResultsTex.results_body(datasets, table, index);
|
||||||
bestResultsMd.results_body(datasets, table);
|
bestResultsMd.results_body(datasets, table);
|
||||||
}
|
}
|
||||||
for (auto const& dataset_ : datasets) {
|
for (auto const& dataset_ : datasets) {
|
||||||
@@ -326,14 +326,14 @@ namespace platform {
|
|||||||
messageOutputFile("Excel", excel_report.getFileName());
|
messageOutputFile("Excel", excel_report.getFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void BestResults::reportAll(bool excel, bool tex)
|
void BestResults::reportAll(bool excel, bool tex, bool index)
|
||||||
{
|
{
|
||||||
auto models = getModels();
|
auto models = getModels();
|
||||||
// Build the table of results
|
// Build the table of results
|
||||||
json table = buildTableResults(models);
|
json table = buildTableResults(models);
|
||||||
std::vector<std::string> datasets = getDatasets(table.begin().value());
|
std::vector<std::string> datasets = getDatasets(table.begin().value());
|
||||||
// Print the table of results
|
// Print the table of results
|
||||||
printTableResults(models, table, tex);
|
printTableResults(models, table, tex, index);
|
||||||
// Compute the Friedman test
|
// Compute the Friedman test
|
||||||
std::map<std::string, std::map<std::string, float>> ranksModels;
|
std::map<std::string, std::map<std::string, float>> ranksModels;
|
||||||
if (friedman) {
|
if (friedman) {
|
||||||
|
@@ -13,7 +13,7 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
std::string build();
|
std::string build();
|
||||||
void reportSingle(bool excel);
|
void reportSingle(bool excel);
|
||||||
void reportAll(bool excel, bool tex);
|
void reportAll(bool excel, bool tex, bool index);
|
||||||
void buildAll();
|
void buildAll();
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> getModels();
|
std::vector<std::string> getModels();
|
||||||
@@ -21,7 +21,7 @@ namespace platform {
|
|||||||
std::vector<std::string> loadResultFiles();
|
std::vector<std::string> loadResultFiles();
|
||||||
void messageOutputFile(const std::string& title, const std::string& fileName);
|
void messageOutputFile(const std::string& title, const std::string& fileName);
|
||||||
json buildTableResults(std::vector<std::string> models);
|
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);
|
json loadFile(const std::string& fileName);
|
||||||
void listFile();
|
void listFile();
|
||||||
std::string path;
|
std::string path;
|
||||||
|
@@ -12,7 +12,7 @@ namespace platform {
|
|||||||
exit(1);
|
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;
|
this->models = models;
|
||||||
auto file_name = Paths::tex() + Paths::tex_output();
|
auto file_name = Paths::tex() + Paths::tex_output();
|
||||||
@@ -29,7 +29,8 @@ namespace platform {
|
|||||||
handler << "\\renewcommand{\\tabcolsep }{0.07cm} " << std::endl;
|
handler << "\\renewcommand{\\tabcolsep }{0.07cm} " << std::endl;
|
||||||
handler << "\\caption{Accuracy results(mean $\\pm$ std) for all the algorithms and datasets} " << 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 << "\\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 << "\\hline " << std::endl;
|
||||||
handler << "" << std::endl;
|
handler << "" << std::endl;
|
||||||
for (const auto& model : models) {
|
for (const auto& model : models) {
|
||||||
@@ -38,13 +39,12 @@ namespace platform {
|
|||||||
handler << "\\\\" << std::endl;
|
handler << "\\\\" << std::endl;
|
||||||
handler << "\\hline" << 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;
|
int i = 0;
|
||||||
for (auto const& dataset : datasets) {
|
for (auto const& dataset : datasets) {
|
||||||
// Find out max value for this dataset
|
// Find out max value for this dataset
|
||||||
double max_value = 0;
|
double max_value = 0;
|
||||||
// Find out the max value for this dataset
|
|
||||||
for (const auto& model : models) {
|
for (const auto& model : models) {
|
||||||
double value;
|
double value;
|
||||||
try {
|
try {
|
||||||
@@ -57,7 +57,10 @@ namespace platform {
|
|||||||
max_value = value;
|
max_value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handler << ++i << " ";
|
if (index)
|
||||||
|
handler << ++i << " ";
|
||||||
|
else
|
||||||
|
handler << dataset << " ";
|
||||||
for (const auto& model : models) {
|
for (const auto& model : models) {
|
||||||
double value = table[model].at(dataset).at(0).get<double>();
|
double value = table[model].at(dataset).at(0).get<double>();
|
||||||
double std_value = table[model].at(dataset).at(3).get<double>();
|
double std_value = table[model].at(dataset).at(3).get<double>();
|
||||||
|
@@ -9,13 +9,14 @@ namespace platform {
|
|||||||
using json = nlohmann::ordered_json;
|
using json = nlohmann::ordered_json;
|
||||||
class BestResultsTex {
|
class BestResultsTex {
|
||||||
public:
|
public:
|
||||||
BestResultsTex() = default;
|
BestResultsTex(bool dataset_name = true) : dataset_name(dataset_name) {};
|
||||||
~BestResultsTex() = default;
|
~BestResultsTex() = default;
|
||||||
void results_header(const std::vector<std::string>& models, const std::string& date);
|
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);
|
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 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);
|
void holm_test(struct HolmResult& holmResult, const std::string& date);
|
||||||
private:
|
private:
|
||||||
|
bool dataset_name;
|
||||||
void openTexFile(const std::string& name);
|
void openTexFile(const std::string& name);
|
||||||
std::ofstream handler;
|
std::ofstream handler;
|
||||||
std::vector<std::string> models;
|
std::vector<std::string> models;
|
||||||
|
@@ -16,7 +16,8 @@ void manageArguments(argparse::ArgumentParser& program)
|
|||||||
program.add_argument("-s", "--score").default_value("accuracy").help("Filter results of the score name supplied");
|
program.add_argument("-s", "--score").default_value("accuracy").help("Filter results of the score name supplied");
|
||||||
program.add_argument("--friedman").help("Friedman test").default_value(false).implicit_value(true);
|
program.add_argument("--friedman").help("Friedman test").default_value(false).implicit_value(true);
|
||||||
program.add_argument("--excel").help("Output to excel").default_value(false).implicit_value(true);
|
program.add_argument("--excel").help("Output to excel").default_value(false).implicit_value(true);
|
||||||
program.add_argument("--tex").help("Output result table to TeX file").default_value(false).implicit_value(true);
|
program.add_argument("--tex").help("Output results to TeX & Markdown files").default_value(false).implicit_value(true);
|
||||||
|
program.add_argument("--index").help("In tex output show the index of the dataset instead of the name to save space").default_value(false).implicit_value(true);
|
||||||
program.add_argument("--level").help("significance level").default_value(0.05).scan<'g', double>().action([](const std::string& value) {
|
program.add_argument("--level").help("significance level").default_value(0.05).scan<'g', double>().action([](const std::string& value) {
|
||||||
try {
|
try {
|
||||||
auto k = std::stod(value);
|
auto k = std::stod(value);
|
||||||
@@ -38,7 +39,7 @@ int main(int argc, char** argv)
|
|||||||
argparse::ArgumentParser program("b_best", { platform_project_version.begin(), platform_project_version.end() });
|
argparse::ArgumentParser program("b_best", { platform_project_version.begin(), platform_project_version.end() });
|
||||||
manageArguments(program);
|
manageArguments(program);
|
||||||
std::string model, dataset, score;
|
std::string model, dataset, score;
|
||||||
bool build, report, friedman, excel, tex;
|
bool build, report, friedman, excel, tex, index;
|
||||||
double level;
|
double level;
|
||||||
try {
|
try {
|
||||||
program.parse_args(argc, argv);
|
program.parse_args(argc, argv);
|
||||||
@@ -48,6 +49,7 @@ int main(int argc, char** argv)
|
|||||||
friedman = program.get<bool>("friedman");
|
friedman = program.get<bool>("friedman");
|
||||||
excel = program.get<bool>("excel");
|
excel = program.get<bool>("excel");
|
||||||
tex = program.get<bool>("tex");
|
tex = program.get<bool>("tex");
|
||||||
|
index = program.get<bool>("index");
|
||||||
level = program.get<double>("level");
|
level = program.get<double>("level");
|
||||||
if (model == "" || score == "") {
|
if (model == "" || score == "") {
|
||||||
throw std::runtime_error("Model and score name must be supplied");
|
throw std::runtime_error("Model and score name must be supplied");
|
||||||
@@ -67,7 +69,7 @@ int main(int argc, char** argv)
|
|||||||
auto results = platform::BestResults(platform::Paths::results(), score, model, dataset, friedman, level);
|
auto results = platform::BestResults(platform::Paths::results(), score, model, dataset, friedman, level);
|
||||||
if (model == "any") {
|
if (model == "any") {
|
||||||
results.buildAll();
|
results.buildAll();
|
||||||
results.reportAll(excel, tex);
|
results.reportAll(excel, tex, index);
|
||||||
} else {
|
} else {
|
||||||
std::string fileName = results.build();
|
std::string fileName = results.build();
|
||||||
std::cout << Colors::GREEN() << fileName << " created!" << Colors::RESET() << std::endl;
|
std::cout << Colors::GREEN() << fileName << " created!" << Colors::RESET() << std::endl;
|
||||||
|
Reference in New Issue
Block a user