Enhance b_main experiment output

This commit is contained in:
2024-01-29 18:50:53 +01:00
parent a220b847d4
commit 889668bf00
3 changed files with 31 additions and 14 deletions

View File

@@ -39,15 +39,12 @@ namespace platform {
auto result = Result(path, file);
auto data = result.load();
for (auto const& item : data.at("results")) {
bool update = false;
// Check if results file contains only one dataset
bool update = true;
auto datasetName = item.at("dataset").get<std::string>();
if (bests.contains(datasetName)) {
if (item.at("score").get<double>() > bests[datasetName].at(0).get<double>()) {
update = true;
if (item.at("score").get<double>() < bests[datasetName].at(0).get<double>()) {
update = false;
}
} else {
update = true;
}
if (update) {
bests[datasetName] = { item.at("score").get<double>(), item.at("hyperparameters"), file };

View File

@@ -103,12 +103,31 @@ namespace platform {
void Experiment::go(std::vector<std::string> filesToProcess, bool quiet)
{
std::cout << "*** Starting experiment: " << title << " ***" << std::endl;
for (auto fileName : filesToProcess) {
std::cout << "- " << setw(20) << left << fileName << " " << right << flush;
cross_validation(fileName, quiet);
std::cout << std::endl;
if (fileName.size() > max_name)
max_name = fileName.size();
}
std::cout << Colors::MAGENTA() << "*** Starting experiment: " << title << " ***" << Colors::RESET() << std::endl << std::endl;
if (!quiet) {
std::cout << Colors::GREEN() << " Status Meaning" << std::endl;
std::cout << " ------ -----------------------------" << Colors::RESET() << std::endl;
std::cout << " ( " << Colors::GREEN() << "a" << Colors::RESET() << " ) Fitting model with train dataset" << std::endl;
std::cout << " ( " << Colors::GREEN() << "b" << Colors::RESET() << " ) Scoring train dataset" << std::endl;
std::cout << " ( " << Colors::GREEN() << "c" << Colors::RESET() << " ) Scoring test dataset" << std::endl << std::endl;
std::cout << Colors::YELLOW() << "Note: fold number in this color means fitting had issues such as not using all features in BoostAODE classifier" << std::endl << std::endl;
std::cout << Colors::GREEN() << left << " # " << setw(max_name) << "Dataset" << " #Samp #Feat Seed Status" << std::endl;
std::cout << " --- " << string(max_name, '-') << " ----- ----- ---- " << string(4 + 3 * nfolds, '-') << Colors::RESET() << std::endl;
}
int num = 0;
for (auto fileName : filesToProcess) {
if (!quiet)
std::cout << " " << setw(3) << right << num++ << " " << setw(max_name) << left << fileName << right << flush;
cross_validation(fileName, quiet);
if (!quiet)
std::cout << std::endl;
}
if (!quiet)
std::cout << std::endl;
}
std::string getColor(bayesnet::status_t status)
@@ -141,7 +160,7 @@ namespace platform {
auto samples = datasets.getNSamples(fileName);
auto className = datasets.getClassName(fileName);
if (!quiet) {
std::cout << " (" << setw(5) << samples << "," << setw(3) << features.size() << ") " << flush;
std::cout << " " << setw(5) << samples << " " << setw(5) << features.size() << flush;
}
// Prepare Result
auto result = Result();
@@ -162,11 +181,11 @@ namespace platform {
bool first_seed = true;
for (auto seed : randomSeeds) {
if (!quiet) {
string prefix = "";
string prefix = " ";
if (!first_seed) {
prefix = "\n" + string(36, ' ');
prefix = "\n" + string(18 + max_name, ' ');
}
std::cout << prefix << "(" << setw(4) << seed << ") doing Fold: " << flush;
std::cout << prefix << setw(4) << right << seed << " " << flush;
first_seed = false;
}
folding::Fold* fold;

View File

@@ -96,6 +96,7 @@ namespace platform {
std::vector<int> randomSeeds;
HyperParameters hyperparameters;
int nfolds{ 0 };
int max_name{ 7 }; // max length of dataset name for formatting (default 7)
float duration{ 0 };
json build_json();
};