Add show dataset detail in report
This commit is contained in:
parent
0b7beda78c
commit
64fc7bd9dd
@ -10,14 +10,14 @@ namespace platform {
|
||||
char do_thousands_sep() const { return '.'; }
|
||||
string do_grouping() const { return "\03"; }
|
||||
};
|
||||
|
||||
|
||||
string ReportConsole::headerLine(const string& text)
|
||||
{
|
||||
int n = MAXL - text.length() - 3;
|
||||
n = n < 0 ? 0 : n;
|
||||
return "* " + text + string(n, ' ') + "*\n";
|
||||
}
|
||||
|
||||
|
||||
void ReportConsole::header()
|
||||
{
|
||||
locale mylocale(cout.getloc(), new separated);
|
||||
@ -36,14 +36,21 @@ namespace platform {
|
||||
}
|
||||
void ReportConsole::body()
|
||||
{
|
||||
cout << Colors::GREEN() << "Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl;
|
||||
cout << "============================== ====== ===== === ========= ========= ========= =============== ================== ===============" << endl;
|
||||
cout << Colors::GREEN() << " # Dataset Sampl. Feat. Cls Nodes Edges States Score Time Hyperparameters" << endl;
|
||||
cout << "=== ============================== ====== ===== === ========= ========= ========= =============== ================== ===============" << endl;
|
||||
json lastResult;
|
||||
double totalScore = 0.0;
|
||||
bool odd = true;
|
||||
int index = 0;
|
||||
for (const auto& r : data["results"]) {
|
||||
if (selectedIndex != -1 && index != selectedIndex) {
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
auto color = odd ? Colors::CYAN() : Colors::BLUE();
|
||||
cout << color << setw(30) << left << r["dataset"].get<string>() << " ";
|
||||
cout << color;
|
||||
cout << setw(3) << index++ << " ";
|
||||
cout << setw(30) << left << r["dataset"].get<string>() << " ";
|
||||
cout << setw(6) << right << r["samples"].get<int>() << " ";
|
||||
cout << setw(5) << right << r["features"].get<int>() << " ";
|
||||
cout << setw(3) << right << r["classes"].get<int>() << " ";
|
||||
@ -63,7 +70,7 @@ namespace platform {
|
||||
totalScore += r["score"].get<double>();
|
||||
odd = !odd;
|
||||
}
|
||||
if (data["results"].size() == 1) {
|
||||
if (data["results"].size() == 1 || selectedIndex != -1) {
|
||||
cout << string(MAXL, '*') << endl;
|
||||
cout << headerLine(fVector("Train scores: ", lastResult["scores_train"], 14, 12));
|
||||
cout << headerLine(fVector("Test scores: ", lastResult["scores_test"], 14, 12));
|
||||
|
@ -7,12 +7,13 @@
|
||||
|
||||
namespace platform {
|
||||
using namespace std;
|
||||
const int MAXL = 128;
|
||||
class ReportConsole : public ReportBase{
|
||||
const int MAXL = 132;
|
||||
class ReportConsole : public ReportBase {
|
||||
public:
|
||||
explicit ReportConsole(json data_) : ReportBase(data_) {};
|
||||
explicit ReportConsole(json data_, int index = -1) : ReportBase(data_), selectedIndex(index) {};
|
||||
virtual ~ReportConsole() = default;
|
||||
private:
|
||||
int selectedIndex;
|
||||
string headerLine(const string& text);
|
||||
void header() override;
|
||||
void body() override;
|
||||
|
@ -110,6 +110,17 @@ namespace platform {
|
||||
reporter.show();
|
||||
}
|
||||
}
|
||||
void Results::showIndex(const int index, const int idx) const
|
||||
{
|
||||
auto data = files.at(index).load();
|
||||
if (idx < 0 or idx >= static_cast<int>(data["results"].size())) {
|
||||
cout << "Invalid index" << endl;
|
||||
return;
|
||||
}
|
||||
cout << Colors::YELLOW() << "Showing " << files.at(index).getFilename() << endl;
|
||||
ReportConsole reporter(data, idx);
|
||||
reporter.show();
|
||||
}
|
||||
void Results::menu()
|
||||
{
|
||||
char option;
|
||||
@ -129,9 +140,16 @@ namespace platform {
|
||||
option = line[0];
|
||||
} else {
|
||||
if (all_of(line.begin(), line.end(), ::isdigit)) {
|
||||
index = stoi(line);
|
||||
if (index >= 0 && index < files.size()) {
|
||||
report(index, false);
|
||||
int idx = stoi(line);
|
||||
if (indexList) {
|
||||
index = idx;
|
||||
if (index >= 0 && index < files.size()) {
|
||||
report(index, false);
|
||||
indexList = false;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
showIndex(index, idx);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -144,6 +162,7 @@ namespace platform {
|
||||
break;
|
||||
case 'l':
|
||||
show();
|
||||
indexList = true;
|
||||
break;
|
||||
case 'd':
|
||||
index = getIndex("delete");
|
||||
@ -155,6 +174,7 @@ namespace platform {
|
||||
files.erase(files.begin() + index);
|
||||
cout << "File: " + filename + " deleted!" << endl;
|
||||
show();
|
||||
indexList = true;
|
||||
break;
|
||||
case 'h':
|
||||
index = getIndex("hide");
|
||||
@ -166,21 +186,25 @@ namespace platform {
|
||||
files.erase(files.begin() + index);
|
||||
show();
|
||||
menu();
|
||||
indexList = true;
|
||||
break;
|
||||
case 's':
|
||||
sortList();
|
||||
indexList = true;
|
||||
show();
|
||||
break;
|
||||
case 'r':
|
||||
index = getIndex("report");
|
||||
if (index == -1)
|
||||
break;
|
||||
indexList = false;
|
||||
report(index, false);
|
||||
break;
|
||||
case 'e':
|
||||
index = getIndex("excel");
|
||||
if (index == -1)
|
||||
break;
|
||||
indexList = true;
|
||||
report(index, true);
|
||||
break;
|
||||
default:
|
||||
|
@ -42,10 +42,12 @@ namespace platform {
|
||||
string model;
|
||||
string scoreName;
|
||||
bool complete;
|
||||
bool indexList = true;
|
||||
vector<Result> files;
|
||||
void load(); // Loads the list of results
|
||||
void show() const;
|
||||
void report(const int index, const bool excelReport) const;
|
||||
void showIndex(const int index, const int idx) const;
|
||||
int getIndex(const string& intent) const;
|
||||
void menu();
|
||||
void sortList();
|
||||
|
Loading…
Reference in New Issue
Block a user