Add # models to ReportExcelCompared
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(Platform
|
||||
VERSION 1.0.2
|
||||
VERSION 1.0.4
|
||||
DESCRIPTION "Platform to run Experiments with classifiers."
|
||||
HOMEPAGE_URL "https://github.com/rmontanana/platform"
|
||||
LANGUAGES CXX
|
||||
|
Submodule lib/PyClassifiers updated: 0608c0a52a...11ee490c1c
Submodule lib/catch2 updated: ed6ac8a629...8ac8190e49
Submodule lib/libxlsxwriter updated: b0c76b3396...f6d73b0ae1
@@ -1,6 +1,11 @@
|
||||
include_directories(
|
||||
## Libs
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/src
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/src/classifiers
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/src/ensembles
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/src/bayesian_network
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/src/feature_selection
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/src/utils
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/folding
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/mdlp
|
||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/json/include
|
||||
|
@@ -29,20 +29,39 @@ namespace platform {
|
||||
}
|
||||
void ReportExcelCompared::header()
|
||||
{
|
||||
worksheet_merge_range(worksheet, 0, 0, 0, 20, "Compare Results A vs B", styles["headerFirst"]);
|
||||
worksheet_merge_range(worksheet, 1, 0, 1, 20, "Δ = (A - B) / B", styles["headerRest"]);
|
||||
worksheet_merge_range(worksheet, 0, 0, 0, 23, "Compare Results A vs B", styles["headerFirst"]);
|
||||
worksheet_merge_range(worksheet, 1, 0, 1, 23, "Δ = (A - B) / B", styles["headerRest"]);
|
||||
worksheet_freeze_panes(worksheet, 5, 1);
|
||||
}
|
||||
double diff(double a, double b)
|
||||
{
|
||||
return (a - b) / b;
|
||||
}
|
||||
float compute_model_number(json& rA)
|
||||
{
|
||||
float result = 0;
|
||||
int num = 0;
|
||||
int models = 0;
|
||||
bool average = false;
|
||||
std::string str_models = "Number of models: ";
|
||||
for (const std::string& note : rA["notes"]) {
|
||||
std::size_t found = note.find(str_models);
|
||||
if (found != std::string::npos) {
|
||||
models += stoi(note.substr(found + str_models.size()));
|
||||
num++;
|
||||
average = true;
|
||||
}
|
||||
}
|
||||
if (average)
|
||||
result = models / num;
|
||||
return result;
|
||||
}
|
||||
void ReportExcelCompared::body()
|
||||
{
|
||||
// Body Header
|
||||
auto sizes = std::vector<int>({ 22, 10, 9, 7, 12, 12, 9, 12, 12, 9, 12, 12, 9, 12, 12, 9, 15, 15, 9, 15, 15 });
|
||||
auto sizes = std::vector<int>({ 22, 10, 9, 7, 12, 12, 9, 12, 12, 9, 12, 12, 9, 12, 12, 9, 12, 12, 9, 15, 15, 9, 15, 15 });
|
||||
auto head_a = std::vector<std::string>({ "Dataset", "Samples", "Features", "Classes" });
|
||||
auto head_b = std::vector<std::string>({ "Nodes", "Edges", "States", "Score", "Time" });
|
||||
auto head_b = std::vector<std::string>({ "Models", "Nodes", "Edges", "States", "Score", "Time" });
|
||||
int headerRow = 3;
|
||||
int col = 0;
|
||||
for (const auto& item : head_a) {
|
||||
@@ -68,15 +87,17 @@ namespace platform {
|
||||
row = headerRow + 2;
|
||||
int hypSize_A = 15;
|
||||
int hypSize_B = 15;
|
||||
auto compared = std::vector<std::string>({ "nodes", "leaves", "depth", "score", "time" });
|
||||
auto compared = std::vector<std::string>({ "models", "nodes", "leaves", "depth", "score", "time" });
|
||||
auto compared_data = std::vector<double>(compared.size(), 0.0);
|
||||
auto totals_A = std::vector<double>(compared.size(), 0.0);
|
||||
auto totals_B = std::vector<double>(compared.size(), 0.0);
|
||||
std::string hyperparameters;
|
||||
for (int i = 0; i < data_A["results"].size(); i++) {
|
||||
col = 0;
|
||||
const auto& r_A = data_A["results"][i];
|
||||
const auto& r_B = data_B["results"][i];
|
||||
auto& r_A = data_A["results"][i];
|
||||
auto& r_B = data_B["results"][i];
|
||||
r_A["models"] = compute_model_number(r_A);
|
||||
r_B["models"] = compute_model_number(r_B);
|
||||
for (int j = 0; j < compared.size(); j++) {
|
||||
auto key = compared[j];
|
||||
compared_data[j] = diff(r_A[key].get<double>(), r_B[key].get<double>());
|
||||
@@ -87,21 +108,24 @@ namespace platform {
|
||||
writeInt(row, col++, r_A["samples"].get<int>(), "ints");
|
||||
writeInt(row, col++, r_A["features"].get<int>(), "ints");
|
||||
writeInt(row, col++, r_A["classes"].get<int>(), "ints");
|
||||
writeDouble(row, col++, r_A["models"].get<float>(), "floats");
|
||||
writeDouble(row, col++, r_B["models"].get<float>(), "floats");
|
||||
writeDouble(row, col++, compared_data[0], "percentage");
|
||||
writeDouble(row, col++, r_A["nodes"].get<float>(), "floats");
|
||||
writeDouble(row, col++, r_B["nodes"].get<float>(), "floats");
|
||||
writeDouble(row, col++, compared_data[0], "percentage");
|
||||
writeDouble(row, col++, compared_data[1], "percentage");
|
||||
writeDouble(row, col++, r_A["leaves"].get<float>(), "floats");
|
||||
writeDouble(row, col++, r_B["leaves"].get<float>(), "floats");
|
||||
writeDouble(row, col++, compared_data[1], "percentage");
|
||||
writeDouble(row, col++, compared_data[2], "percentage");
|
||||
writeDouble(row, col++, r_A["depth"].get<double>(), "floats");
|
||||
writeDouble(row, col++, r_B["depth"].get<double>(), "floats");
|
||||
writeDouble(row, col++, compared_data[2], "percentage");
|
||||
writeDouble(row, col++, compared_data[3], "percentage");
|
||||
writeDouble(row, col++, r_A["score"].get<double>(), "result");
|
||||
writeDouble(row, col++, r_B["score"].get<double>(), "result");
|
||||
writeDouble(row, col++, compared_data[3], "percentage");
|
||||
writeDouble(row, col++, compared_data[4], "percentage");
|
||||
writeDouble(row, col++, r_A["time"].get<double>(), "time");
|
||||
writeDouble(row, col++, r_B["time"].get<double>(), "time");
|
||||
writeDouble(row, col++, compared_data[4], "percentage");
|
||||
writeDouble(row, col++, compared_data[5], "percentage");
|
||||
hyperparameters = r_A["hyperparameters"].dump();
|
||||
if (hyperparameters.size() > hypSize_A) {
|
||||
hypSize_A = hyperparameters.size();
|
||||
@@ -123,7 +147,7 @@ namespace platform {
|
||||
void ReportExcelCompared::footer(std::vector<double>& totals_A, std::vector<double>& totals_B, int row)
|
||||
{
|
||||
worksheet_merge_range(worksheet, row, 0, row, 3, "Total", styles["bodyHeader_even"]);
|
||||
auto formats = std::vector<std::string>({ "floats", "floats", "floats", "result", "result" });
|
||||
auto formats = std::vector<std::string>({ "floats", "floats", "floats", "floats", "result", "result" });
|
||||
int col = 4;
|
||||
for (int i = 0; i < totals_A.size(); i++) {
|
||||
writeDouble(row, col++, totals_A[i], formats[i]);
|
||||
|
Reference in New Issue
Block a user