refactor_folders #1
@@ -5,7 +5,7 @@ diagrams:
|
|||||||
type: class
|
type: class
|
||||||
glob:
|
glob:
|
||||||
- src/*.cc
|
- src/*.cc
|
||||||
- src/Command/*.cc
|
- src/modules/*.cc
|
||||||
using_namespace: platform
|
using_namespace: platform
|
||||||
include:
|
include:
|
||||||
namespaces:
|
namespaces:
|
||||||
@@ -17,7 +17,7 @@ diagrams:
|
|||||||
sequence:
|
sequence:
|
||||||
type: sequence
|
type: sequence
|
||||||
glob:
|
glob:
|
||||||
- src/Command/b_main.cc
|
- src/b_main.cc
|
||||||
combine_free_functions_into_file_participants: true
|
combine_free_functions_into_file_participants: true
|
||||||
using_namespace:
|
using_namespace:
|
||||||
- std
|
- std
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,9 +2,9 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
|
"name": "sample",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "sample",
|
|
||||||
"program": "${workspaceFolder}/build_debug/sample/BayesNetSample",
|
"program": "${workspaceFolder}/build_debug/sample/BayesNetSample",
|
||||||
"args": [
|
"args": [
|
||||||
"-d",
|
"-d",
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
"-s",
|
"-s",
|
||||||
"271",
|
"271",
|
||||||
"-p",
|
"-p",
|
||||||
"/Users/rmontanana/Code/discretizbench/datasets/",
|
"${workspaceFolder}/../discretizbench/datasets/",
|
||||||
],
|
],
|
||||||
//"cwd": "${workspaceFolder}/build/sample/",
|
//"cwd": "${workspaceFolder}/build/sample/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "experimentPy",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "experimentPy",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/b_main",
|
"program": "${workspaceFolder}/build_debug/src/b_main",
|
||||||
"args": [
|
"args": [
|
||||||
"-m",
|
"-m",
|
||||||
@@ -36,9 +36,9 @@
|
|||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
"cwd": "${workspaceFolder}/../discretizbench",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "gridsearch",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "gridsearch",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/b_grid",
|
"program": "${workspaceFolder}/build_debug/src/b_grid",
|
||||||
"args": [
|
"args": [
|
||||||
"-m",
|
"-m",
|
||||||
@@ -52,9 +52,9 @@
|
|||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
"cwd": "${workspaceFolder}/../discretizbench",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "experimentBayes",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "experimentBayes",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/b_main",
|
"program": "${workspaceFolder}/build_debug/src/b_main",
|
||||||
"args": [
|
"args": [
|
||||||
"-m",
|
"-m",
|
||||||
@@ -69,23 +69,23 @@
|
|||||||
"cwd": "/home/rmontanana/Code/discretizbench",
|
"cwd": "/home/rmontanana/Code/discretizbench",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "best",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "best",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/b_best",
|
"program": "${workspaceFolder}/build_debug/src/b_best",
|
||||||
"args": [
|
"args": [
|
||||||
"-m",
|
"-m",
|
||||||
"BoostAODE",
|
"BoostAODE",
|
||||||
"-s",
|
"-s",
|
||||||
"accuracy",
|
"accuracy",
|
||||||
"--build",
|
"--excel"
|
||||||
],
|
],
|
||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
"cwd": "${workspaceFolder}/../discretizbench",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "manage",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "manage",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/b_manage",
|
"program": "${workspaceFolder}/build_debug/src/b_manage",
|
||||||
"args": [
|
"args": [
|
||||||
"-n",
|
"-n",
|
||||||
@@ -94,18 +94,20 @@
|
|||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
"cwd": "${workspaceFolder}/../discretizbench",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "list",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "list",
|
|
||||||
"program": "${workspaceFolder}/build_debug/src/b_list",
|
"program": "${workspaceFolder}/build_debug/src/b_list",
|
||||||
"args": [],
|
"args": [
|
||||||
|
"--excel"
|
||||||
|
],
|
||||||
//"cwd": "/Users/rmontanana/Code/discretizbench",
|
//"cwd": "/Users/rmontanana/Code/discretizbench",
|
||||||
"cwd": "${workspaceFolder}/../discretizbench",
|
"cwd": "${workspaceFolder}/../discretizbench",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "test",
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "test",
|
|
||||||
"program": "${workspaceFolder}/build_debug/tests/unit_tests",
|
"program": "${workspaceFolder}/build_debug/tests/unit_tests",
|
||||||
"args": [
|
"args": [
|
||||||
"-c=\"Metrics Test\"",
|
"-c=\"Metrics Test\"",
|
||||||
|
@@ -78,7 +78,6 @@ message("XLSXWRITER_LIB=${XLSXWRITER_LIB}")
|
|||||||
|
|
||||||
# Subdirectories
|
# Subdirectories
|
||||||
# --------------
|
# --------------
|
||||||
set(Platform_MODULES ${Platform_SOURCE_DIR}/src/modules/)
|
|
||||||
add_subdirectory(config)
|
add_subdirectory(config)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(sample)
|
add_subdirectory(sample)
|
||||||
|
16
Makefile
16
Makefile
@@ -96,22 +96,6 @@ test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximu
|
|||||||
done
|
done
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
opt = ""
|
|
||||||
testp: ## Run platform tests (opt="-s") to verbose output the tests, (opt="-c='Stratified Fold Test'") to run only that section
|
|
||||||
@echo ">>> Running Platform tests...";
|
|
||||||
@$(MAKE) clean
|
|
||||||
@cmake --build $(f_debug) --target unit_tests_platform $(n_procs)
|
|
||||||
@if [ -f $(f_debug)/tests/unit_tests_platform ]; then cd $(f_debug)/tests ; ./unit_tests_platform $(opt) ; fi ;
|
|
||||||
@echo ">>> Done";
|
|
||||||
|
|
||||||
opt = ""
|
|
||||||
testb: ## Run Platform tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
|
||||||
@echo ">>> Running Platform tests...";
|
|
||||||
@$(MAKE) clean
|
|
||||||
@cmake --build $(f_debug) --target unit_tests_bayesnet $(n_procs)
|
|
||||||
@if [ -f $(f_debug)/tests/unit_tests_bayesnet ]; then cd $(f_debug)/tests ; ./unit_tests_bayesnet $(opt) ; fi ;
|
|
||||||
@echo ">>> Done";
|
|
||||||
|
|
||||||
coverage: ## Run tests and generate coverage report (build/index.html)
|
coverage: ## Run tests and generate coverage report (build/index.html)
|
||||||
@echo ">>> Building tests with coverage..."
|
@echo ">>> Building tests with coverage..."
|
||||||
@$(MAKE) test
|
@$(MAKE) test
|
||||||
|
Submodule lib/PyClassifiers updated: bd6f6f5837...0608c0a52a
@@ -1,5 +1,6 @@
|
|||||||
include_directories(
|
include_directories(
|
||||||
${Platform_SOURCE_DIR}/src/modules
|
${Platform_SOURCE_DIR}/src/common
|
||||||
|
${Platform_SOURCE_DIR}/src/main
|
||||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/src
|
${Platform_SOURCE_DIR}/lib/PyClassifiers/src
|
||||||
${Python3_INCLUDE_DIRS}
|
${Python3_INCLUDE_DIRS}
|
||||||
${Platform_SOURCE_DIR}/lib/Files
|
${Platform_SOURCE_DIR}/lib/Files
|
||||||
@@ -10,5 +11,5 @@ include_directories(
|
|||||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/json/include
|
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/json/include
|
||||||
${CMAKE_BINARY_DIR}/configured_files/include
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
)
|
)
|
||||||
add_executable(PlatformSample sample.cc ${Platform_MODULES}/Models.cc)
|
add_executable(PlatformSample sample.cc ${Platform_SOURCE_DIR}/src/main/Models.cc)
|
||||||
target_link_libraries(PlatformSample PyClassifiers ArffFiles mdlp "${TORCH_LIBRARIES}")
|
target_link_libraries(PlatformSample PyClassifiers ArffFiles mdlp "${TORCH_LIBRARIES}")
|
@@ -1,10 +1,10 @@
|
|||||||
include_directories(
|
include_directories(
|
||||||
|
## Libs
|
||||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/src
|
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/src
|
||||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/folding
|
${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/mdlp
|
||||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/json/include
|
${Platform_SOURCE_DIR}/lib/PyClassifiers/lib/BayesNet/lib/json/include
|
||||||
${Platform_SOURCE_DIR}/lib/PyClassifiers/src
|
${Platform_SOURCE_DIR}/lib/PyClassifiers/src
|
||||||
${Platform_MODULES}
|
|
||||||
${Platform_SOURCE_DIR}/lib/Files
|
${Platform_SOURCE_DIR}/lib/Files
|
||||||
${Platform_SOURCE_DIR}/lib/mdlp
|
${Platform_SOURCE_DIR}/lib/mdlp
|
||||||
${Platform_SOURCE_DIR}/lib/argparse/include
|
${Platform_SOURCE_DIR}/lib/argparse/include
|
||||||
@@ -13,24 +13,41 @@ include_directories(
|
|||||||
${Python3_INCLUDE_DIRS}
|
${Python3_INCLUDE_DIRS}
|
||||||
${MPI_CXX_INCLUDE_DIRS}
|
${MPI_CXX_INCLUDE_DIRS}
|
||||||
${CMAKE_BINARY_DIR}/configured_files/include
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
|
## Platform
|
||||||
|
${Platform_SOURCE_DIR}/src/common
|
||||||
|
${Platform_SOURCE_DIR}/src/best
|
||||||
|
${Platform_SOURCE_DIR}/src/grid
|
||||||
|
${Platform_SOURCE_DIR}/src/main
|
||||||
|
${Platform_SOURCE_DIR}/src/manage
|
||||||
|
${Platform_SOURCE_DIR}/src/reports
|
||||||
)
|
)
|
||||||
|
|
||||||
set(best_sources BestResults.cc Result.cc Statistics.cc BestResultsExcel.cc ReportExcel.cc ReportBase.cc Datasets.cc Dataset.cc ExcelFile.cc)
|
# b_best
|
||||||
list(TRANSFORM best_sources PREPEND ${Platform_MODULES})
|
set(best_sources b_best.cc BestResults.cc Statistics.cc BestResultsExcel.cc)
|
||||||
add_executable(b_best b_best.cc ${best_sources})
|
list(TRANSFORM best_sources PREPEND best/)
|
||||||
set(grid_sources GridSearch.cc GridData.cc HyperParameters.cc Datasets.cc Dataset.cc Models.cc)
|
add_executable(b_best ${best_sources} main/Result.cc reports/ReportExcel.cc reports/ReportBase.cc reports/ExcelFile.cc common/Datasets.cc common/Dataset.cc)
|
||||||
list(TRANSFORM grid_sources PREPEND ${Platform_MODULES})
|
target_link_libraries(b_best Boost::boost "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}" ArffFiles mdlp)
|
||||||
add_executable(b_grid b_grid.cc ${grid_sources})
|
|
||||||
add_executable(b_list b_list.cc ${Platform_MODULES}Datasets.cc ${Platform_MODULES}Dataset.cc)
|
|
||||||
set(main_sources Experiment.cc Datasets.cc Dataset.cc Models.cc HyperParameters.cc ReportConsole.cc ReportBase.cc Result.cc)
|
|
||||||
list(TRANSFORM main_sources PREPEND ${Platform_MODULES})
|
|
||||||
add_executable(b_main b_main.cc ${main_sources})
|
|
||||||
set(manage_sources Results.cc ManageResults.cc CommandParser.cc Result.cc ReportConsole.cc ReportExcel.cc ReportBase.cc Datasets.cc Dataset.cc ExcelFile.cc)
|
|
||||||
list(TRANSFORM manage_sources PREPEND ${Platform_MODULES})
|
|
||||||
add_executable(b_manage b_manage.cc ${manage_sources})
|
|
||||||
|
|
||||||
target_link_libraries(b_best Boost::boost "${XLSXWRITER_LIB}" "${TORCH_LIBRARIES}" ArffFiles mdlp)
|
# b_grid
|
||||||
|
set(grid_sources b_grid.cc GridSearch.cc GridData.cc)
|
||||||
|
list(TRANSFORM grid_sources PREPEND grid/)
|
||||||
|
add_executable(b_grid ${grid_sources} main/HyperParameters.cc main/Models.cc common/Datasets.cc common/Dataset.cc)
|
||||||
target_link_libraries(b_grid PyClassifiers ${MPI_CXX_LIBRARIES} ArffFiles)
|
target_link_libraries(b_grid PyClassifiers ${MPI_CXX_LIBRARIES} ArffFiles)
|
||||||
target_link_libraries(b_list ArffFiles mdlp "${TORCH_LIBRARIES}")
|
|
||||||
target_link_libraries(b_main PyClassifiers BayesNet ArffFiles mdlp "${TORCH_LIBRARIES}")
|
# b_list
|
||||||
|
set(list_sources b_list.cc DatasetsExcel.cc)
|
||||||
|
list(TRANSFORM list_sources PREPEND list/)
|
||||||
|
add_executable(b_list ${list_sources} common/Datasets.cc common/Dataset.cc reports/ReportExcel.cc reports/ExcelFile.cc reports/ReportBase.cc)
|
||||||
|
target_link_libraries(b_list "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}" ArffFiles mdlp)
|
||||||
|
|
||||||
|
# b_main
|
||||||
|
set(main_sources b_main.cc Experiment.cc Models.cc HyperParameters.cc)
|
||||||
|
list(TRANSFORM main_sources PREPEND main/)
|
||||||
|
add_executable(b_main ${main_sources} common/Datasets.cc common/Dataset.cc reports/ReportConsole.cc reports/ReportBase.cc main/Result.cc)
|
||||||
|
target_link_libraries(b_main PyClassifiers BayesNet ArffFiles mdlp)
|
||||||
|
|
||||||
|
# b_manage
|
||||||
|
set(manage_sources b_manage.cc ManageResults.cc CommandParser.cc Results.cc)
|
||||||
|
list(TRANSFORM manage_sources PREPEND manage/)
|
||||||
|
add_executable(b_manage ${manage_sources} main/Result.cc reports/ReportConsole.cc reports/ReportExcel.cc reports/ReportBase.cc reports/ExcelFile.cc common/Datasets.cc common/Dataset.cc)
|
||||||
target_link_libraries(b_manage "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}" ArffFiles mdlp)
|
target_link_libraries(b_manage "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}" ArffFiles mdlp)
|
@@ -302,9 +302,9 @@ namespace platform {
|
|||||||
// 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());
|
||||||
BestResultsExcel excel(score, datasets);
|
BestResultsExcel excel_report(score, datasets);
|
||||||
excel.reportSingle(model, path + bestResultFile());
|
excel_report.reportSingle(model, path + bestResultFile());
|
||||||
messageExcelFile(excel.getFileName());
|
messageExcelFile(excel_report.getFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void BestResults::reportAll(bool excel)
|
void BestResults::reportAll(bool excel)
|
@@ -32,7 +32,8 @@ namespace platform {
|
|||||||
}
|
}
|
||||||
BestResultsExcel::BestResultsExcel(const std::string& score, const std::vector<std::string>& datasets) : score(score), datasets(datasets)
|
BestResultsExcel::BestResultsExcel(const std::string& score, const std::vector<std::string>& datasets) : score(score), datasets(datasets)
|
||||||
{
|
{
|
||||||
workbook = workbook_new((Paths::excel() + fileName).c_str());
|
file_name = "BestResults.xlsx";
|
||||||
|
workbook = workbook_new(getFileName().c_str());
|
||||||
setProperties("Best Results");
|
setProperties("Best Results");
|
||||||
int maxDatasetName = (*max_element(datasets.begin(), datasets.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); })).size();
|
int maxDatasetName = (*max_element(datasets.begin(), datasets.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); })).size();
|
||||||
datasetNameSize = std::max(datasetNameSize, maxDatasetName);
|
datasetNameSize = std::max(datasetNameSize, maxDatasetName);
|
||||||
@@ -170,10 +171,7 @@ namespace platform {
|
|||||||
doFriedman();
|
doFriedman();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string BestResultsExcel::getFileName()
|
|
||||||
{
|
|
||||||
return Paths::excel() + fileName;
|
|
||||||
}
|
|
||||||
void BestResultsExcel::header(bool ranks)
|
void BestResultsExcel::header(bool ranks)
|
||||||
{
|
{
|
||||||
row = 0;
|
row = 0;
|
@@ -9,13 +9,12 @@ using json = nlohmann::json;
|
|||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
|
|
||||||
class BestResultsExcel : ExcelFile {
|
class BestResultsExcel : public ExcelFile {
|
||||||
public:
|
public:
|
||||||
BestResultsExcel(const std::string& score, const std::vector<std::string>& datasets);
|
BestResultsExcel(const std::string& score, const std::vector<std::string>& datasets);
|
||||||
~BestResultsExcel();
|
~BestResultsExcel();
|
||||||
void reportAll(const std::vector<std::string>& models, const json& table, const std::map<std::string, std::map<std::string, float>>& ranks, bool friedman, double significance);
|
void reportAll(const std::vector<std::string>& models, const json& table, const std::map<std::string, std::map<std::string, float>>& ranks, bool friedman, double significance);
|
||||||
void reportSingle(const std::string& model, const std::string& fileName);
|
void reportSingle(const std::string& model, const std::string& fileName);
|
||||||
std::string getFileName();
|
|
||||||
private:
|
private:
|
||||||
void build();
|
void build();
|
||||||
void header(bool ranks);
|
void header(bool ranks);
|
||||||
@@ -24,7 +23,6 @@ namespace platform {
|
|||||||
void formatColumns();
|
void formatColumns();
|
||||||
void doFriedman();
|
void doFriedman();
|
||||||
void addConditionalFormat(std::string formula);
|
void addConditionalFormat(std::string formula);
|
||||||
const std::string fileName = "BestResults.xlsx";
|
|
||||||
std::string score;
|
std::string score;
|
||||||
std::vector<std::string> models;
|
std::vector<std::string> models;
|
||||||
std::vector<std::string> datasets;
|
std::vector<std::string> datasets;
|
@@ -65,5 +65,6 @@ int main(int argc, char** argv)
|
|||||||
std::cout << Colors::GREEN() << fileName << " created!" << Colors::RESET() << std::endl;
|
std::cout << Colors::GREEN() << fileName << " created!" << Colors::RESET() << std::endl;
|
||||||
results.reportSingle(excel);
|
results.reportSingle(excel);
|
||||||
}
|
}
|
||||||
|
std::cout << Colors::RESET();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
55
src/list/DatasetsExcel.cc
Normal file
55
src/list/DatasetsExcel.cc
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#include <sstream>
|
||||||
|
#include "DatasetsExcel.h"
|
||||||
|
#include "Paths.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace platform {
|
||||||
|
DatasetsExcel::DatasetsExcel(json& data) : data(data), ExcelFile()
|
||||||
|
{
|
||||||
|
file_name = "datasets.xlsx";
|
||||||
|
workbook = workbook_new(getFileName().c_str());
|
||||||
|
createFormats();
|
||||||
|
setProperties("Datasets");
|
||||||
|
}
|
||||||
|
DatasetsExcel::~DatasetsExcel()
|
||||||
|
{
|
||||||
|
workbook_close(workbook);
|
||||||
|
}
|
||||||
|
void DatasetsExcel::report()
|
||||||
|
{
|
||||||
|
int datasetNameSize = 25; // Min size of the column
|
||||||
|
int balanceSize = 75; // Min size of the column
|
||||||
|
worksheet = workbook_add_worksheet(workbook, "Datasets");
|
||||||
|
worksheet_merge_range(worksheet, 0, 0, 0, 5, "Datasets", styles["headerFirst"]);
|
||||||
|
formatColumns(datasetNameSize, balanceSize);
|
||||||
|
// Body header
|
||||||
|
row = 2;
|
||||||
|
int col = 0;
|
||||||
|
int i = 0;
|
||||||
|
for (const auto& name : { "Nº", "Dataset", "Samples", "Features", "Classes", "Balance" }) {
|
||||||
|
writeString(row, col++, name, "bodyHeader");
|
||||||
|
}
|
||||||
|
for (auto& [key, value] : data.items()) {
|
||||||
|
row++;
|
||||||
|
if (key.size() > datasetNameSize) {
|
||||||
|
datasetNameSize = key.size();
|
||||||
|
}
|
||||||
|
writeInt(row, 0, i++, "ints");
|
||||||
|
writeString(row, 1, key.c_str(), "text");
|
||||||
|
writeInt(row, 2, value["samples"], "ints");
|
||||||
|
writeInt(row, 3, value["features"], "ints");
|
||||||
|
writeInt(row, 4, value["classes"], "ints");
|
||||||
|
writeString(row, 5, value["balance"].get<std::string>().c_str(), "text");
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
formatColumns(datasetNameSize, balanceSize);
|
||||||
|
}
|
||||||
|
void DatasetsExcel::formatColumns(int dataset, int balance)
|
||||||
|
{
|
||||||
|
worksheet_freeze_panes(worksheet, 4, 2);
|
||||||
|
std::vector<int> columns_sizes = { 5, dataset, 10, 10, 10, balance };
|
||||||
|
for (int i = 0; i < columns_sizes.size(); ++i) {
|
||||||
|
worksheet_set_column(worksheet, i, i, columns_sizes.at(i), NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
src/list/DatasetsExcel.h
Normal file
23
src/list/DatasetsExcel.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef DATASETS_EXCEL_H
|
||||||
|
#define DATASETS_EXCEL_H
|
||||||
|
#include "ExcelFile.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
namespace platform {
|
||||||
|
|
||||||
|
class DatasetsExcel : public ExcelFile {
|
||||||
|
public:
|
||||||
|
explicit DatasetsExcel(json& data);
|
||||||
|
~DatasetsExcel();
|
||||||
|
void report();
|
||||||
|
private:
|
||||||
|
void formatColumns(int dataset, int balance);
|
||||||
|
json data;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif //DATASETS_EXCEL_H
|
@@ -1,8 +1,12 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
#include <argparse/argparse.hpp>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
#include "Paths.h"
|
#include "Paths.h"
|
||||||
#include "Colors.h"
|
#include "Colors.h"
|
||||||
#include "Datasets.h"
|
#include "Datasets.h"
|
||||||
|
#include "DatasetsExcel.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
const int BALANCE_LENGTH = 75;
|
const int BALANCE_LENGTH = 75;
|
||||||
|
|
||||||
@@ -12,7 +16,7 @@ struct separated : numpunct<char> {
|
|||||||
std::string do_grouping() const { return "\03"; }
|
std::string do_grouping() const { return "\03"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
void outputBalance(const std::string& balance)
|
std::string outputBalance(const std::string& balance)
|
||||||
{
|
{
|
||||||
auto temp = std::string(balance);
|
auto temp = std::string(balance);
|
||||||
while (temp.size() > BALANCE_LENGTH - 1) {
|
while (temp.size() > BALANCE_LENGTH - 1) {
|
||||||
@@ -21,12 +25,19 @@ void outputBalance(const std::string& balance)
|
|||||||
std::cout << setw(52) << " ";
|
std::cout << setw(52) << " ";
|
||||||
temp = temp.substr(BALANCE_LENGTH);
|
temp = temp.substr(BALANCE_LENGTH);
|
||||||
}
|
}
|
||||||
std::cout << temp << std::endl;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
auto data = platform::Datasets(false, platform::Paths::datasets());
|
auto datasets = platform::Datasets(false, platform::Paths::datasets());
|
||||||
|
argparse::ArgumentParser program("b_list", { project_version.begin(), project_version.end() });
|
||||||
|
program.add_argument("--excel")
|
||||||
|
.help("Output in Excel format")
|
||||||
|
.default_value(false)
|
||||||
|
.implicit_value(true);
|
||||||
|
program.parse_args(argc, argv);
|
||||||
|
auto excel = program.get<bool>("--excel");
|
||||||
locale mylocale(std::cout.getloc(), new separated);
|
locale mylocale(std::cout.getloc(), new separated);
|
||||||
locale::global(mylocale);
|
locale::global(mylocale);
|
||||||
std::cout.imbue(mylocale);
|
std::cout.imbue(mylocale);
|
||||||
@@ -34,23 +45,36 @@ int main(int argc, char** argv)
|
|||||||
std::string balanceBars = std::string(BALANCE_LENGTH, '=');
|
std::string balanceBars = std::string(BALANCE_LENGTH, '=');
|
||||||
std::cout << "=== ============================== ====== ===== === " << balanceBars << std::endl;
|
std::cout << "=== ============================== ====== ===== === " << balanceBars << std::endl;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (const auto& dataset : data.getNames()) {
|
json data;
|
||||||
|
for (const auto& dataset : datasets.getNames()) {
|
||||||
auto color = num % 2 ? Colors::CYAN() : Colors::BLUE();
|
auto color = num % 2 ? Colors::CYAN() : Colors::BLUE();
|
||||||
std::cout << color << setw(3) << right << num++ << " ";
|
std::cout << color << setw(3) << right << num++ << " ";
|
||||||
std::cout << setw(30) << left << dataset << " ";
|
std::cout << setw(30) << left << dataset << " ";
|
||||||
data.loadDataset(dataset);
|
datasets.loadDataset(dataset);
|
||||||
auto nSamples = data.getNSamples(dataset);
|
auto nSamples = datasets.getNSamples(dataset);
|
||||||
std::cout << setw(6) << right << nSamples << " ";
|
std::cout << setw(6) << right << nSamples << " ";
|
||||||
std::cout << setw(5) << right << data.getFeatures(dataset).size() << " ";
|
std::cout << setw(5) << right << datasets.getFeatures(dataset).size() << " ";
|
||||||
std::cout << setw(3) << right << data.getNClasses(dataset) << " ";
|
std::cout << setw(3) << right << datasets.getNClasses(dataset) << " ";
|
||||||
std::stringstream oss;
|
std::stringstream oss;
|
||||||
std::string sep = "";
|
std::string sep = "";
|
||||||
for (auto number : data.getClassesCounts(dataset)) {
|
for (auto number : datasets.getClassesCounts(dataset)) {
|
||||||
oss << sep << std::setprecision(2) << fixed << (float)number / nSamples * 100.0 << "% (" << number << ")";
|
oss << sep << std::setprecision(2) << fixed << (float)number / nSamples * 100.0 << "% (" << number << ")";
|
||||||
sep = " / ";
|
sep = " / ";
|
||||||
}
|
}
|
||||||
outputBalance(oss.str());
|
auto balance = outputBalance(oss.str());
|
||||||
|
std::cout << balance << std::endl;
|
||||||
|
// Store data for Excel report
|
||||||
|
data[dataset] = json::object();
|
||||||
|
data[dataset]["samples"] = nSamples;
|
||||||
|
data[dataset]["features"] = datasets.getFeatures(dataset).size();
|
||||||
|
data[dataset]["classes"] = datasets.getNClasses(dataset);
|
||||||
|
data[dataset]["balance"] = oss.str();
|
||||||
}
|
}
|
||||||
std::cout << Colors::RESET() << std::endl;
|
std::cout << Colors::RESET() << std::endl;
|
||||||
|
if (excel) {
|
||||||
|
auto report = platform::DatasetsExcel(data);
|
||||||
|
report.report();
|
||||||
|
std::cout << "Output saved in " << report.getFileName() << std::endl;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@@ -164,7 +164,7 @@ namespace platform {
|
|||||||
if (indexList) {
|
if (indexList) {
|
||||||
std::tie(option, index) = parser.parse(Colors::GREEN(), mainOptions, 'r', numFiles - 1);
|
std::tie(option, index) = parser.parse(Colors::GREEN(), mainOptions, 'r', numFiles - 1);
|
||||||
} else {
|
} else {
|
||||||
std::tie(option, subIndex) = parser.parse(Colors::MAGENTA(), listOptions, 'r', results.at(index).getJson()["results"].size() - 1);
|
std::tie(option, subIndex) = parser.parse(Colors::CYAN(), listOptions, 'r', results.at(index).getJson()["results"].size() - 1);
|
||||||
}
|
}
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 'q':
|
case 'q':
|
@@ -1,4 +1,5 @@
|
|||||||
#include "ExcelFile.h"
|
#include "ExcelFile.h"
|
||||||
|
#include "Paths.h"
|
||||||
|
|
||||||
namespace platform {
|
namespace platform {
|
||||||
ExcelFile::ExcelFile()
|
ExcelFile::ExcelFile()
|
||||||
@@ -26,6 +27,10 @@ namespace platform {
|
|||||||
{
|
{
|
||||||
return workbook;
|
return workbook;
|
||||||
}
|
}
|
||||||
|
std::string ExcelFile::getFileName()
|
||||||
|
{
|
||||||
|
return Paths::excel() + file_name;
|
||||||
|
}
|
||||||
void ExcelFile::setProperties(std::string title)
|
void ExcelFile::setProperties(std::string title)
|
||||||
{
|
{
|
||||||
char line[title.size() + 1];
|
char line[title.size() + 1];
|
||||||
@@ -82,11 +87,13 @@ namespace platform {
|
|||||||
if (name == "textCentered") {
|
if (name == "textCentered") {
|
||||||
format_set_align(style, LXW_ALIGN_CENTER);
|
format_set_align(style, LXW_ALIGN_CENTER);
|
||||||
format_set_font_size(style, normalSize);
|
format_set_font_size(style, normalSize);
|
||||||
|
format_set_align(style, LXW_ALIGN_VERTICAL_CENTER);
|
||||||
format_set_border(style, LXW_BORDER_THIN);
|
format_set_border(style, LXW_BORDER_THIN);
|
||||||
} else if (name == "text") {
|
} else if (name == "text") {
|
||||||
format_set_font_size(style, normalSize);
|
format_set_font_size(style, normalSize);
|
||||||
format_set_border(style, LXW_BORDER_THIN);
|
format_set_border(style, LXW_BORDER_THIN);
|
||||||
format_set_align(style, LXW_ALIGN_VERTICAL_CENTER);
|
format_set_align(style, LXW_ALIGN_VERTICAL_CENTER);
|
||||||
|
format_set_text_wrap(style);
|
||||||
} else if (name == "bodyHeader") {
|
} else if (name == "bodyHeader") {
|
||||||
format_set_bold(style);
|
format_set_bold(style);
|
||||||
format_set_font_size(style, normalSize);
|
format_set_font_size(style, normalSize);
|
||||||
@@ -96,18 +103,22 @@ namespace platform {
|
|||||||
format_set_bg_color(style, lxw_color_t(colorTitle));
|
format_set_bg_color(style, lxw_color_t(colorTitle));
|
||||||
} else if (name == "result") {
|
} else if (name == "result") {
|
||||||
format_set_font_size(style, normalSize);
|
format_set_font_size(style, normalSize);
|
||||||
|
format_set_align(style, LXW_ALIGN_VERTICAL_CENTER);
|
||||||
format_set_border(style, LXW_BORDER_THIN);
|
format_set_border(style, LXW_BORDER_THIN);
|
||||||
format_set_num_format(style, "0.0000000");
|
format_set_num_format(style, "0.0000000");
|
||||||
} else if (name == "time") {
|
} else if (name == "time") {
|
||||||
format_set_font_size(style, normalSize);
|
format_set_font_size(style, normalSize);
|
||||||
format_set_border(style, LXW_BORDER_THIN);
|
format_set_border(style, LXW_BORDER_THIN);
|
||||||
|
format_set_align(style, LXW_ALIGN_VERTICAL_CENTER);
|
||||||
format_set_num_format(style, "#,##0.000000");
|
format_set_num_format(style, "#,##0.000000");
|
||||||
} else if (name == "ints") {
|
} else if (name == "ints") {
|
||||||
format_set_font_size(style, normalSize);
|
format_set_font_size(style, normalSize);
|
||||||
format_set_num_format(style, "###,##0");
|
format_set_num_format(style, "###,##0");
|
||||||
|
format_set_align(style, LXW_ALIGN_VERTICAL_CENTER);
|
||||||
format_set_border(style, LXW_BORDER_THIN);
|
format_set_border(style, LXW_BORDER_THIN);
|
||||||
} else if (name == "floats") {
|
} else if (name == "floats") {
|
||||||
format_set_border(style, LXW_BORDER_THIN);
|
format_set_border(style, LXW_BORDER_THIN);
|
||||||
|
format_set_align(style, LXW_ALIGN_VERTICAL_CENTER);
|
||||||
format_set_font_size(style, normalSize);
|
format_set_font_size(style, normalSize);
|
||||||
format_set_num_format(style, "#,##0.00");
|
format_set_num_format(style, "#,##0.00");
|
||||||
}
|
}
|
@@ -19,6 +19,7 @@ namespace platform {
|
|||||||
ExcelFile(lxw_workbook* workbook);
|
ExcelFile(lxw_workbook* workbook);
|
||||||
ExcelFile(lxw_workbook* workbook, lxw_worksheet* worksheet);
|
ExcelFile(lxw_workbook* workbook, lxw_worksheet* worksheet);
|
||||||
lxw_workbook* getWorkbook();
|
lxw_workbook* getWorkbook();
|
||||||
|
std::string getFileName();
|
||||||
protected:
|
protected:
|
||||||
void setProperties(std::string title);
|
void setProperties(std::string title);
|
||||||
void writeString(int row, int col, const std::string& text, const std::string& style = "");
|
void writeString(int row, int col, const std::string& text, const std::string& style = "");
|
||||||
@@ -36,6 +37,7 @@ namespace platform {
|
|||||||
uint32_t colorTitle;
|
uint32_t colorTitle;
|
||||||
uint32_t colorOdd;
|
uint32_t colorOdd;
|
||||||
uint32_t colorEven;
|
uint32_t colorEven;
|
||||||
|
std::string file_name;
|
||||||
private:
|
private:
|
||||||
void setDefault();
|
void setDefault();
|
||||||
};
|
};
|
@@ -94,10 +94,10 @@ namespace platform {
|
|||||||
std::cout << headerLine(fVector("Test scores: ", lastResult["scores_test"], 14, 12));
|
std::cout << headerLine(fVector("Test scores: ", lastResult["scores_test"], 14, 12));
|
||||||
std::cout << headerLine(fVector("Train times: ", lastResult["times_train"], 10, 3));
|
std::cout << headerLine(fVector("Train times: ", lastResult["times_train"], 10, 3));
|
||||||
std::cout << headerLine(fVector("Test times: ", lastResult["times_test"], 10, 3));
|
std::cout << headerLine(fVector("Test times: ", lastResult["times_test"], 10, 3));
|
||||||
std::cout << std::string(MAXL, '*') << std::endl;
|
|
||||||
} else {
|
} else {
|
||||||
footer(totalScore);
|
footer(totalScore);
|
||||||
}
|
}
|
||||||
|
std::cout << std::string(MAXL, '*') << Colors::RESET() << std::endl;
|
||||||
}
|
}
|
||||||
void ReportConsole::showSummary()
|
void ReportConsole::showSummary()
|
||||||
{
|
{
|
||||||
@@ -124,6 +124,5 @@ namespace platform {
|
|||||||
if (!getExistBestFile() && compare) {
|
if (!getExistBestFile() && compare) {
|
||||||
std::cout << headerLine("*** Best Results File not found. Couldn't compare any result!");
|
std::cout << headerLine("*** Best Results File not found. Couldn't compare any result!");
|
||||||
}
|
}
|
||||||
std::cout << std::string(MAXL, '*') << std::endl << Colors::RESET();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,6 +9,7 @@ namespace platform {
|
|||||||
ReportExcel::ReportExcel(json data_, bool compare, lxw_workbook* workbook, lxw_worksheet* worksheet) : ReportBase(data_, compare), ExcelFile(workbook, worksheet)
|
ReportExcel::ReportExcel(json data_, bool compare, lxw_workbook* workbook, lxw_worksheet* worksheet) : ReportBase(data_, compare), ExcelFile(workbook, worksheet)
|
||||||
{
|
{
|
||||||
createFile();
|
createFile();
|
||||||
|
createFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportExcel::formatColumns()
|
void ReportExcel::formatColumns()
|
||||||
@@ -49,7 +50,6 @@ namespace platform {
|
|||||||
createWorksheet();
|
createWorksheet();
|
||||||
}
|
}
|
||||||
setProperties(data["title"].get<std::string>());
|
setProperties(data["title"].get<std::string>());
|
||||||
createFormats();
|
|
||||||
formatColumns();
|
formatColumns();
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user