Refactor to accept new Library structure

This commit is contained in:
2024-03-08 22:20:13 +01:00
parent b7398db9b1
commit 7e4ee0a9a9
46 changed files with 122 additions and 132 deletions

View File

@@ -3,12 +3,8 @@
#include <string>
#include <string_view>
#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR @
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR @
#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH @
static constexpr std::string_view project_name = "@PROJECT_NAME@";
static constexpr std::string_view project_version = "@PROJECT_VERSION@";
static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";
static constexpr std::string_view git_sha = "@GIT_SHA@";
static constexpr std::string_view data_path = "@Platform_SOURCE_DIR@/tests/data/";
static constexpr std::string_view platform_project_name = "@PROJECT_NAME@";
static constexpr std::string_view platform_project_version = "@PROJECT_VERSION@";
static constexpr std::string_view platform_project_description = "@PROJECT_DESCRIPTION@";
static constexpr std::string_view platform_git_sha = "@GIT_SHA@";
static constexpr std::string_view platform_data_path = "@Platform_SOURCE_DIR@/tests/data/";

View File

@@ -1,4 +1,4 @@
filter = src/
exclude-directories = build/lib/
exclude-directories = build_debug/lib/
print-summary = yes
sort-percentage = yes

View File

@@ -7,9 +7,8 @@ include_directories(
${Platform_SOURCE_DIR}/lib/argparse/include
${Platform_SOURCE_DIR}/lib/folding
${Platform_SOURCE_DIR}/lib/json/include
/usr/local/include/bayesnet
/usr/local/include/pyclassifiers
${CMAKE_BINARY_DIR}/configured_files/include
/usr/local/include
)
add_executable(PlatformSample sample.cc ${Platform_SOURCE_DIR}/src/main/Models.cc)
# target_link_libraries(PlatformSample "${PyClassifiers}" "${BayesNet}" ArffFiles mdlp "${TORCH_LIBRARIES}")
target_link_libraries(PlatformSample "${PyClassifiers}" "${BayesNet}" ArffFiles mdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::python Boost::numpy)

View File

@@ -1,19 +1,19 @@
#include <iostream>
#include <torch/torch.h>
#include <string>
#include <map>
#include <fstream>
#include <torch/torch.h>
#include <argparse/argparse.hpp>
#include <nlohmann/json.hpp>
#include <ArffFiles.h>
#include <utils/BayesMetrics.h>
#include <CPPFImdlp.h>
#include <folding.hpp>
#include <bayesnet/utils/BayesMetrics.h>
#include "Models.h"
#include "modelRegister.h"
#include "config.h"
const std::string PATH = { data_path.begin(), data_path.end() };
const std::string PATH = { platform_data_path.begin(), platform_data_path.end() };
pair<std::vector<mdlp::labels_t>, map<std::string, int>> discretize(std::vector<mdlp::samples_t>& X, mdlp::labels_t& y, std::vector<std::string> features)
{

View File

@@ -10,15 +10,9 @@ include_directories(
${MPI_CXX_INCLUDE_DIRS}
${TORCH_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/configured_files/include
/usr/local/include/bayesnet
/usr/local/include/pyclassifiers
/usr/local/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
${Platform_SOURCE_DIR}/src
)
# b_best

View File

@@ -4,12 +4,12 @@
#include <iostream>
#include <sstream>
#include <algorithm>
#include "BestResults.h"
#include "Result.h"
#include "Colors.h"
#include "Statistics.h"
#include "common/Colors.h"
#include "common/CLocale.h"
#include "main/Result.h"
#include "BestResultsExcel.h"
#include "CLocale.h"
#include "Statistics.h"
#include "BestResults.h"
namespace fs = std::filesystem;

View File

@@ -1,10 +1,10 @@
#include <sstream>
#include "BestResultsExcel.h"
#include "Paths.h"
#include <map>
#include <nlohmann/json.hpp>
#include "common/Paths.h"
#include "reports/ReportExcel.h"
#include "Statistics.h"
#include "ReportExcel.h"
#include "BestResultsExcel.h"
namespace platform {
json loadResultData(const std::string& fileName)

View File

@@ -1,9 +1,9 @@
#ifndef BESTRESULTS_EXCEL_H
#define BESTRESULTS_EXCEL_H
#include "ExcelFile.h"
#include <vector>
#include <map>
#include <nlohmann/json.hpp>
#include "reports/ExcelFile.h"
using json = nlohmann::json;

View File

@@ -3,7 +3,7 @@
#include <string>
#include <map>
#include <utility>
#include "DotEnv.h"
#include "common/DotEnv.h"
namespace platform {
class BestScore {
public:

View File

@@ -1,10 +1,10 @@
#include <sstream>
#include "Statistics.h"
#include "Colors.h"
#include "Symbols.h"
#include <boost/math/distributions/chi_squared.hpp>
#include <boost/math/distributions/normal.hpp>
#include "CLocale.h"
#include "common/Colors.h"
#include "common/Symbols.h"
#include "common/CLocale.h"
#include "Statistics.h"
namespace platform {

View File

@@ -1,8 +1,8 @@
#include <iostream>
#include <argparse/argparse.hpp>
#include "Paths.h"
#include "common/Paths.h"
#include "common/Colors.h"
#include "BestResults.h"
#include "Colors.h"
#include "config.h"
void manageArguments(argparse::ArgumentParser& program)
@@ -29,7 +29,7 @@ void manageArguments(argparse::ArgumentParser& program)
int main(int argc, char** argv)
{
argparse::ArgumentParser program("b_best", { project_version.begin(), project_version.end() });
argparse::ArgumentParser program("b_best", { platform_project_version.begin(), platform_project_version.end() });
manageArguments(program);
std::string model, score;
bool build, report, friedman, excel;

View File

@@ -1,5 +1,6 @@
#ifndef COLORS_H
#define COLORS_H
#include <string>
class Colors {
public:
static std::string MAGENTA() { return "\033[1;35m"; }

View File

@@ -1,6 +1,6 @@
#include "Dataset.h"
#include "ArffFiles.h"
#include <ArffFiles.h>
#include <fstream>
#include "Dataset.h"
namespace platform {
Dataset::Dataset(const Dataset& dataset) : path(dataset.path), name(dataset.name), className(dataset.className), n_samples(dataset.n_samples), n_features(dataset.n_features), features(dataset.features), states(dataset.states), loaded(dataset.loaded), discretize(dataset.discretize), X(dataset.X), y(dataset.y), Xv(dataset.Xv), Xd(dataset.Xd), yv(dataset.yv), fileType(dataset.fileType)
{

View File

@@ -4,7 +4,7 @@
#include <map>
#include <vector>
#include <string>
#include "CPPFImdlp.h"
#include <CPPFImdlp.h>
#include "Utils.h"
namespace platform {
enum fileType_t { CSV, ARFF, RDATA };

View File

@@ -1,5 +1,5 @@
#include "Datasets.h"
#include <fstream>
#include "Datasets.h"
namespace platform {
void Datasets::load()
{

View File

@@ -1,5 +1,5 @@
#include "GridData.h"
#include <fstream>
#include "GridData.h"
namespace platform {
GridData::GridData(const std::string& fileName)

View File

@@ -1,11 +1,11 @@
#include <iostream>
#include <cstddef>
#include <torch/torch.h>
#include <folding.hpp>
#include "main/Models.h"
#include "common/Paths.h"
#include "common/Colors.h"
#include "GridSearch.h"
#include "Models.h"
#include "Paths.h"
#include "folding.hpp"
#include "Colors.h"
namespace platform {
std::string get_date()

View File

@@ -4,10 +4,10 @@
#include <map>
#include <mpi.h>
#include <nlohmann/json.hpp>
#include "Datasets.h"
#include "HyperParameters.h"
#include "common/Datasets.h"
#include "common/Timer.h"
#include "main/HyperParameters.h"
#include "GridData.h"
#include "Timer.h"
namespace platform {
using json = nlohmann::json;

View File

@@ -4,13 +4,13 @@
#include <tuple>
#include <nlohmann/json.hpp>
#include <mpi.h>
#include "DotEnv.h"
#include "Models.h"
#include "modelRegister.h"
#include "main/Models.h"
#include "main/modelRegister.h"
#include "common/Paths.h"
#include "common/Timer.h"
#include "common/Colors.h"
#include "common/DotEnv.h"
#include "GridSearch.h"
#include "Paths.h"
#include "Timer.h"
#include "Colors.h"
#include "config.h"
using json = nlohmann::json;
@@ -223,7 +223,7 @@ int main(int argc, char** argv)
//
// Manage arguments
//
argparse::ArgumentParser program("b_grid", { project_version.begin(), project_version.end() });
argparse::ArgumentParser program("b_grid", { platform_project_version.begin(), platform_project_version.end() });
// grid dump subparser
argparse::ArgumentParser dump_command("dump");
dump_command.add_description("Dump the combinations of hyperparameters of a model.");

View File

@@ -1,6 +1,6 @@
#include <sstream>
#include "common/Paths.h"
#include "DatasetsExcel.h"
#include "Paths.h"
namespace platform {

View File

@@ -1,9 +1,9 @@
#ifndef DATASETS_EXCEL_H
#define DATASETS_EXCEL_H
#include "ExcelFile.h"
#include <vector>
#include <map>
#include <nlohmann/json.hpp>
#include "reports/ExcelFile.h"
using json = nlohmann::json;

View File

@@ -2,9 +2,9 @@
#include <locale>
#include <argparse/argparse.hpp>
#include <nlohmann/json.hpp>
#include "Paths.h"
#include "Colors.h"
#include "Datasets.h"
#include "common/Paths.h"
#include "common/Colors.h"
#include "common/Datasets.h"
#include "DatasetsExcel.h"
#include "config.h"
@@ -31,7 +31,7 @@ std::string outputBalance(const std::string& balance)
int main(int argc, char** argv)
{
auto datasets = platform::Datasets(false, platform::Paths::datasets());
argparse::ArgumentParser program("b_list", { project_version.begin(), project_version.end() });
argparse::ArgumentParser program("b_list", { platform_project_version.begin(), platform_project_version.end() });
program.add_argument("--excel")
.help("Output in Excel format")
.default_value(false)

View File

@@ -1,8 +1,8 @@
#include "Experiment.h"
#include "Datasets.h"
#include "common/Datasets.h"
#include "reports/ReportConsole.h"
#include "common/Paths.h"
#include "Models.h"
#include "ReportConsole.h"
#include "Paths.h"
#include "Experiment.h"
namespace platform {
using json = nlohmann::json;

View File

@@ -3,8 +3,8 @@
#include <torch/torch.h>
#include <nlohmann/json.hpp>
#include <string>
#include "folding.hpp"
#include "BaseClassifier.h"
#include <folding.hpp>
#include "bayesnet/BaseClassifier.h"
#include "HyperParameters.h"
#include "Result.h"

View File

@@ -1,7 +1,7 @@
#include "HyperParameters.h"
#include <fstream>
#include <sstream>
#include <iostream>
#include "HyperParameters.h"
namespace platform {
HyperParameters::HyperParameters(const std::vector<std::string>& datasets, const json& hyperparameters_)

View File

@@ -1,21 +1,21 @@
#ifndef MODELS_H
#define MODELS_H
#include <map>
#include "BaseClassifier.h"
#include "ensembles/AODE.h"
#include "ensembles/AODELd.h"
#include "ensembles/BoostAODE.h"
#include "classifiers/TAN.h"
#include "classifiers/KDB.h"
#include "classifiers/SPODE.h"
#include "classifiers/TANLd.h"
#include "classifiers/KDBLd.h"
#include "classifiers/SPODELd.h"
#include "STree.h"
#include "ODTE.h"
#include "SVC.h"
#include "XGBoost.h"
#include "RandomForest.h"
#include <bayesnet/BaseClassifier.h>
#include <bayesnet/ensembles/AODE.h>
#include <bayesnet/ensembles/AODELd.h>
#include <bayesnet/ensembles/BoostAODE.h>
#include <bayesnet/classifiers/TAN.h>
#include <bayesnet/classifiers/KDB.h>
#include <bayesnet/classifiers/SPODE.h>
#include <bayesnet/classifiers/TANLd.h>
#include <bayesnet/classifiers/KDBLd.h>
#include <bayesnet/classifiers/SPODELd.h>
#include <pyclassifiers/STree.h>
#include <pyclassifiers/ODTE.h>
#include <pyclassifiers/SVC.h>
#include <pyclassifiers/XGBoost.h>
#include <pyclassifiers/RandomForest.h>
namespace platform {
class Models {
private:

View File

@@ -1,12 +1,12 @@
#include "Result.h"
#include <filesystem>
#include <fstream>
#include <sstream>
#include "BestScore.h"
#include "Colors.h"
#include "DotEnv.h"
#include "CLocale.h"
#include "Paths.h"
#include "best/BestScore.h"
#include "common/Colors.h"
#include "common/DotEnv.h"
#include "common/CLocale.h"
#include "common/Paths.h"
#include "Result.h"
namespace platform {
std::string get_actual_date()

View File

@@ -4,9 +4,9 @@
#include <vector>
#include <string>
#include <nlohmann/json.hpp>
#include "HyperParameters.h"
#include "PartialResult.h"
#include "Timer.h"
#include "common/Timer.h"
#include "main/HyperParameters.h"
#include "main/PartialResult.h"
namespace platform {
using json = nlohmann::json;

View File

@@ -2,11 +2,11 @@
#include <argparse/argparse.hpp>
#include <nlohmann/json.hpp>
#include "Experiment.h"
#include "Datasets.h"
#include "DotEnv.h"
#include "common/Datasets.h"
#include "common/DotEnv.h"
#include "common/Paths.h"
#include "Models.h"
#include "modelRegister.h"
#include "Paths.h"
#include "config.h"
@@ -55,7 +55,7 @@ void manageArguments(argparse::ArgumentParser& program)
int main(int argc, char** argv)
{
argparse::ArgumentParser program("b_main", { project_version.begin(), project_version.end() });
argparse::ArgumentParser program("b_main", { platform_project_version.begin(), platform_project_version.end() });
manageArguments(program);
std::string file_name, model_name, title, hyperparameters_file;
json hyperparameters_json;

View File

@@ -2,8 +2,8 @@
#include <iostream>
#include <sstream>
#include <algorithm>
#include "Colors.h"
#include "Utils.h"
#include "common/Colors.h"
#include "common/Utils.h"
namespace platform {
void CommandParser::messageError(const std::string& message)

View File

@@ -1,13 +1,13 @@
#include "ManageResults.h"
#include "CommandParser.h"
#include <filesystem>
#include <tuple>
#include "Colors.h"
#include "CLocale.h"
#include "Paths.h"
#include "ReportConsole.h"
#include "ReportExcel.h"
#include "ReportExcelCompared.h"
#include "common/Colors.h"
#include "common/CLocale.h"
#include "common/Paths.h"
#include "reports/ReportConsole.h"
#include "reports/ReportExcel.h"
#include "reports/ReportExcelCompared.h"
#include "CommandParser.h"
#include "ManageResults.h"
namespace platform {

View File

@@ -1,7 +1,7 @@
#ifndef MANAGE_RESULTS_H
#define MANAGE_RESULTS_H
#include <xlsxwriter.h>
#include "Results.h"
#include "xlsxwriter.h"
namespace platform {
class ManageResults {

View File

@@ -1,5 +1,5 @@
#include "Results.h"
#include <algorithm>
#include "Results.h"
namespace platform {
Results::Results(const std::string& path, const std::string& model, const std::string& score, bool complete, bool partial) :

View File

@@ -4,7 +4,7 @@
#include <vector>
#include <string>
#include <nlohmann/json.hpp>
#include "Result.h"
#include "main/Result.h"
namespace platform {
using json = nlohmann::json;
class Results {

View File

@@ -33,7 +33,7 @@ void manageArguments(argparse::ArgumentParser& program, int argc, char** argv)
int main(int argc, char** argv)
{
auto program = argparse::ArgumentParser("b_manage", { project_version.begin(), project_version.end() });
auto program = argparse::ArgumentParser("b_manage", { platform_project_version.begin(), platform_project_version.end() });
manageArguments(program, argc, argv);
int number = program.get<int>("number");
std::string model = program.get<std::string>("model");

View File

@@ -1,5 +1,5 @@
#include "common/Paths.h"
#include "ExcelFile.h"
#include "Paths.h"
namespace platform {
ExcelFile::ExcelFile()

View File

@@ -3,7 +3,7 @@
#include <locale>
#include <string>
#include <map>
#include "xlsxwriter.h"
#include <xlsxwriter.h>
namespace platform {
struct separated : std::numpunct<char> {

View File

@@ -1,8 +1,8 @@
#include <sstream>
#include <locale>
#include "Datasets.h"
#include "common/Datasets.h"
#include "common/DotEnv.h"
#include "ReportBase.h"
#include "DotEnv.h"
namespace platform {
ReportBase::ReportBase(json data_, bool compare) : data(data_), compare(compare), margin(0.1)

View File

@@ -2,9 +2,9 @@
#define REPORTBASE_H
#include <string>
#include <iostream>
#include "Paths.h"
#include "Symbols.h"
#include <nlohmann/json.hpp>
#include "common/Paths.h"
#include "common/Symbols.h"
using json = nlohmann::json;
namespace platform {

View File

@@ -1,9 +1,9 @@
#include <iostream>
#include <sstream>
#include <locale>
#include "best/BestScore.h"
#include "common/CLocale.h"
#include "ReportConsole.h"
#include "BestScore.h"
#include "CLocale.h"
namespace platform {
std::string ReportConsole::headerLine(const std::string& text, int utf = 0)

View File

@@ -1,8 +1,8 @@
#ifndef REPORTCONSOLE_H
#define REPORTCONSOLE_H
#include <string>
#include "common/Colors.h"
#include "ReportBase.h"
#include "Colors.h"
namespace platform {
const int MAXL = 133;

View File

@@ -1,7 +1,7 @@
#include <sstream>
#include <locale>
#include "best/BestScore.h"
#include "ReportExcel.h"
#include "BestScore.h"
namespace platform {

View File

@@ -1,10 +1,10 @@
#ifndef REPORTEXCEL_H
#define REPORTEXCEL_H
#include<map>
#include "xlsxwriter.h"
#include <map>
#include <xlsxwriter.h>
#include "common/Colors.h"
#include "ReportBase.h"
#include "ExcelFile.h"
#include "Colors.h"
namespace platform {
class ReportExcel : public ReportBase, public ExcelFile {
public:

View File

@@ -5,8 +5,8 @@ if(ENABLE_TESTING)
${Platform_SOURCE_DIR}/lib/argparse/include
${Platform_SOURCE_DIR}/lib/mdlp
${Platform_SOURCE_DIR}/lib/Files
/usr/local/include/bayesnet
/usr/local/include/pyclassifiers
${CMAKE_BINARY_DIR}/configured_files/include
/usr/local/include
)
set(TEST_SOURCES_PLATFORM TestUtils.cc TestPlatform.cc)
add_executable(${TEST_PLATFORM} ${TEST_SOURCES_PLATFORM})

View File

@@ -11,6 +11,6 @@
TEST_CASE("Test Python Classifiers score", "[PyClassifiers]")
{
std::string version = { project_version.begin(), project_version.end() };
std::string version = { platform_project_version.begin(), platform_project_version.end() };
REQUIRE(version == "1.0.4");
}

View File

@@ -5,7 +5,7 @@ class Paths {
public:
static std::string datasets()
{
return { data_path.begin(), data_path.end() };
return { platform_data_path.begin(), platform_data_path.end() };
}
};