From 2a9652b4506897abeda7487c08af3af6e9cfa981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Sat, 18 Jan 2025 20:31:58 +0100 Subject: [PATCH] Fix b_main order of datasets if --datasets parameter used --- src/commands/b_grid.cpp | 1 - src/main/Experiment.cpp | 18 ++++++++++++++++++ src/main/Experiment.h | 17 +---------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/commands/b_grid.cpp b/src/commands/b_grid.cpp index 29f89eb..d932ea5 100644 --- a/src/commands/b_grid.cpp +++ b/src/commands/b_grid.cpp @@ -33,7 +33,6 @@ void assignModel(argparse::ArgumentParser& parser) } ); } - void add_search_args(argparse::ArgumentParser& program) { auto env = platform::DotEnv(); diff --git a/src/main/Experiment.cpp b/src/main/Experiment.cpp index 0208175..3acc7ba 100644 --- a/src/main/Experiment.cpp +++ b/src/main/Experiment.cpp @@ -43,6 +43,22 @@ namespace platform { } } } + Experiment& Experiment::setSmoothSrategy(const std::string& smooth_strategy) + { + this->smooth_strategy = smooth_strategy; + this->result.setSmoothStrategy(smooth_strategy); + if (smooth_strategy == "ORIGINAL") + smooth_type = bayesnet::Smoothing_t::ORIGINAL; + else if (smooth_strategy == "LAPLACE") + smooth_type = bayesnet::Smoothing_t::LAPLACE; + else if (smooth_strategy == "CESTNIK") + smooth_type = bayesnet::Smoothing_t::CESTNIK; + else { + std::cerr << "Experiment: Unknown smoothing strategy: " << smooth_strategy << std::endl; + exit(1); + } + return *this; + } void Experiment::go() { for (auto fileName : filesToTest) { @@ -64,6 +80,8 @@ namespace platform { std::cout << " --- " << string(max_name, '-') << " ----- ----- ---- " << string(4 + 3 * nfolds, '-') << " ----------" << Colors::RESET() << std::endl; } int num = 0; + // Sort files to test to have a consistent order even if --datasets is used + std::stable_sort(filesToTest.begin(), filesToTest.end()); for (auto fileName : filesToTest) { if (!quiet) std::cout << " " << setw(3) << right << num++ << " " << setw(max_name) << left << fileName << right << flush; diff --git a/src/main/Experiment.h b/src/main/Experiment.h index 0553833..bfad61c 100644 --- a/src/main/Experiment.h +++ b/src/main/Experiment.h @@ -25,22 +25,7 @@ namespace platform { { this->discretization_algo = discretization_algo; this->result.setDiscretizationAlgorithm(discretization_algo); return *this; } - Experiment& setSmoothSrategy(const std::string& smooth_strategy) - { - this->smooth_strategy = smooth_strategy; - this->result.setSmoothStrategy(smooth_strategy); - if (smooth_strategy == "ORIGINAL") - smooth_type = bayesnet::Smoothing_t::ORIGINAL; - else if (smooth_strategy == "LAPLACE") - smooth_type = bayesnet::Smoothing_t::LAPLACE; - else if (smooth_strategy == "CESTNIK") - smooth_type = bayesnet::Smoothing_t::CESTNIK; - else { - std::cerr << "Experiment: Unknown smoothing strategy: " << smooth_strategy << std::endl; - exit(1); - } - return *this; - } + Experiment& setSmoothSrategy(const std::string& smooth_strategy); Experiment& setLanguageVersion(const std::string& language_version) { this->result.setLanguageVersion(language_version); return *this; } Experiment& setDiscretized(bool discretized) { this->discretized = discretized; result.setDiscretized(discretized); return *this; } Experiment& setStratified(bool stratified) { this->stratified = stratified; result.setStratified(stratified); return *this; }