Compare commits

...

3 Commits

64 changed files with 104 additions and 131 deletions

View File

@@ -4,8 +4,8 @@ diagrams:
Platform:
type: class
glob:
- src/*.cc
- src/modules/*.cc
- src/*.cpp
- src/modules/*.cpp
using_namespace: platform
include:
namespaces:
@@ -17,7 +17,7 @@ diagrams:
sequence:
type: sequence
glob:
- src/b_main.cc
- src/b_main.cpp
combine_free_functions_into_file_participants: true
using_namespace:
- std

View File

@@ -85,7 +85,7 @@ add_subdirectory(lib/Files)
add_subdirectory(config)
add_subdirectory(src)
add_subdirectory(sample)
file(GLOB Platform_SOURCES CONFIGURE_DEPENDS ${Platform_SOURCE_DIR}/src/*.cc)
file(GLOB Platform_SOURCES CONFIGURE_DEPENDS ${Platform_SOURCE_DIR}/src/*.cpp)
# Testing
# -------

View File

@@ -976,7 +976,7 @@ INPUT_FILE_ENCODING =
# Note the list of default checked file patterns might differ from the list of
# default file extension mappings.
#
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
# If left blank the following patterns are tested:*.c, *.cpp, *.cxx, *.cpp,
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml,
# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C
@@ -984,7 +984,7 @@ INPUT_FILE_ENCODING =
# *.vhdl, *.ucf, *.qsf and *.ice.
FILE_PATTERNS = *.c \
*.cc \
*.cpp \
*.cxx \
*.cpp \
*.c++ \

View File

@@ -10,5 +10,5 @@ include_directories(
${CMAKE_BINARY_DIR}/configured_files/include
/usr/local/include
)
add_executable(PlatformSample sample.cc ${Platform_SOURCE_DIR}/src/main/Models.cc)
add_executable(PlatformSample sample.cpp ${Platform_SOURCE_DIR}/src/main/Models.cpp)
target_link_libraries(PlatformSample "${PyClassifiers}" "${BayesNet}" ArffFiles mdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::python Boost::numpy)

View File

@@ -16,37 +16,37 @@ include_directories(
)
# b_best
set(best_sources b_best.cc BestResults.cc Statistics.cc BestResultsExcel.cc)
set(best_sources b_best.cpp BestResults.cpp Statistics.cpp BestResultsExcel.cpp)
list(TRANSFORM best_sources PREPEND best/)
add_executable(
b_best ${best_sources} main/Result.cc
reports/ReportExcel.cc reports/ReportBase.cc reports/ExcelFile.cc common/Datasets.cc common/Dataset.cc main/Models.cc)
b_best ${best_sources} main/Result.cpp
reports/ReportExcel.cpp reports/ReportBase.cpp reports/ExcelFile.cpp common/Datasets.cpp common/Dataset.cpp main/Models.cpp)
target_link_libraries(b_best Boost::boost "${PyClassifiers}" "${BayesNet}" ArffFiles mdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::python Boost::numpy "${XLSXWRITER_LIB}")
# b_grid
set(grid_sources b_grid.cc GridSearch.cc GridData.cc)
set(grid_sources b_grid.cpp GridSearch.cpp GridData.cpp)
list(TRANSFORM grid_sources PREPEND grid/)
add_executable(b_grid ${grid_sources} main/HyperParameters.cc main/Models.cc common/Datasets.cc common/Dataset.cc)
add_executable(b_grid ${grid_sources} main/HyperParameters.cpp main/Models.cpp common/Datasets.cpp common/Dataset.cpp)
target_link_libraries(b_grid ${MPI_CXX_LIBRARIES} "${PyClassifiers}" "${BayesNet}" ArffFiles mdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::python Boost::numpy)
# b_list
set(list_sources b_list.cc DatasetsExcel.cc)
set(list_sources b_list.cpp DatasetsExcel.cpp)
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)
add_executable(b_list ${list_sources} common/Datasets.cpp common/Dataset.cpp reports/ReportExcel.cpp reports/ExcelFile.cpp reports/ReportBase.cpp)
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)
set(main_sources b_main.cpp Experiment.cpp Models.cpp HyperParameters.cpp)
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)
add_executable(b_main ${main_sources} common/Datasets.cpp common/Dataset.cpp reports/ReportConsole.cpp reports/ReportBase.cpp main/Result.cpp)
target_link_libraries(b_main "${PyClassifiers}" "${BayesNet}" ArffFiles mdlp ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::python Boost::numpy)
# b_manage
set(manage_sources b_manage.cc ManageResults.cc CommandParser.cc Results.cc)
set(manage_sources b_manage.cpp ManageResults.cpp CommandParser.cpp ResultsManager.cpp)
list(TRANSFORM manage_sources PREPEND manage/)
add_executable(
b_manage ${manage_sources} main/Result.cc
reports/ReportConsole.cc reports/ReportExcel.cc reports/ReportExcelCompared.cc reports/ReportBase.cc reports/ExcelFile.cc
common/Datasets.cc common/Dataset.cc
b_manage ${manage_sources} main/Result.cpp
reports/ReportConsole.cpp reports/ReportExcel.cpp reports/ReportExcelCompared.cpp reports/ReportBase.cpp reports/ExcelFile.cpp
common/Datasets.cpp common/Dataset.cpp
)
target_link_libraries(b_manage "${TORCH_LIBRARIES}" "${XLSXWRITER_LIB}" ArffFiles mdlp)

View File

@@ -1,5 +1,5 @@
#ifndef BESTRESULTS_H
#define BESTRESULTS_H
#pragma once
#include <string>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
@@ -34,4 +34,3 @@ namespace platform {
int maxDatasetName = 0;
};
}
#endif //BESTRESULTS_H

View File

@@ -1,5 +1,5 @@
#ifndef BESTRESULTS_EXCEL_H
#define BESTRESULTS_EXCEL_H
#pragma once
#include <vector>
#include <map>
#include <nlohmann/json.hpp>
@@ -34,4 +34,3 @@ namespace platform {
int datasetNameSize = 25; // Min size of the column
};
}
#endif //BESTRESULTS_EXCEL_H

View File

@@ -1,5 +1,5 @@
#ifndef BESTSCORE_H
#define BESTSCORE_H
#pragma once
#include <string>
#include <map>
#include <utility>
@@ -24,5 +24,3 @@ namespace platform {
}
};
}
#endif

View File

@@ -1,5 +1,5 @@
#ifndef STATISTICS_H
#define STATISTICS_H
#pragma once
#include <iostream>
#include <vector>
#include <map>
@@ -60,4 +60,3 @@ namespace platform {
std::map<std::string, std::map<std::string, float>> ranksModels;
};
}
#endif // !STATISTICS_H

View File

@@ -1,5 +1,5 @@
#ifndef LOCALE_H
#define LOCALE_H
#pragma once
#include <locale>
#include <iostream>
#include <string>
@@ -19,4 +19,3 @@ namespace platform {
}
};
}
#endif

View File

@@ -1,5 +1,5 @@
#ifndef COLORS_H
#define COLORS_H
#pragma once
#include <string>
class Colors {
public:
@@ -13,4 +13,3 @@ public:
static std::string IBLUE() { return "\033[0;94m"; }
static std::string RESET() { return "\033[0m"; }
};
#endif // COLORS_H

View File

@@ -1,5 +1,5 @@
#ifndef DATASET_H
#define DATASET_H
#pragma once
#include <torch/torch.h>
#include <map>
#include <vector>
@@ -75,4 +75,3 @@ namespace platform {
};
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef DATASETS_H
#define DATASETS_H
#pragma once
#include "Dataset.h"
namespace platform {
class Datasets {
@@ -27,5 +27,3 @@ namespace platform {
std::string toString() const;
};
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef DOTENV_H
#define DOTENV_H
#pragma once
#include <string>
#include <map>
#include <fstream>
@@ -52,4 +52,3 @@ namespace platform {
}
};
}
#endif

View File

@@ -1,5 +1,5 @@
#ifndef PATHS_H
#define PATHS_H
#pragma once
#include <string>
#include <filesystem>
#include "DotEnv.h"
@@ -36,4 +36,3 @@ namespace platform {
}
};
}
#endif

View File

@@ -1,5 +1,5 @@
#ifndef SYMBOLS_H
#define SYMBOLS_H
#pragma once
#include <string>
namespace platform {
class Symbols {
@@ -15,4 +15,3 @@ namespace platform {
inline static const std::string notebook{ "\U0001F5C8" };
};
}
#endif // !SYMBOLS_H

View File

@@ -1,5 +1,5 @@
#ifndef TIMER_H
#define TIMER_H
#pragma once
#include <chrono>
#include <string>
#include <sstream>
@@ -40,4 +40,3 @@ namespace platform {
}
};
} /* namespace platform */
#endif /* TIMER_H */

View File

@@ -1,5 +1,5 @@
#ifndef UTILS_H
#define UTILS_H
#pragma once
#include <sstream>
#include <string>
#include <vector>
@@ -27,4 +27,3 @@ namespace platform {
return result;
}
}
#endif

View File

@@ -1,5 +1,5 @@
#ifndef GRIDDATA_H
#define GRIDDATA_H
#pragma once
#include <string>
#include <vector>
#include <map>
@@ -23,4 +23,3 @@ namespace platform {
std::map<std::string, json> grid;
};
} /* namespace platform */
#endif /* GRIDDATA_H */

View File

@@ -1,5 +1,5 @@
#ifndef GRIDSEARCH_H
#define GRIDSEARCH_H
#pragma once
#include <string>
#include <map>
#include <mpi.h>
@@ -57,4 +57,3 @@ namespace platform {
Timer timer; // used to measure the time of the whole process
};
} /* namespace platform */
#endif /* GRIDSEARCH_H */

View File

@@ -1,5 +1,5 @@
#ifndef DATASETS_EXCEL_H
#define DATASETS_EXCEL_H
#pragma once
#include <vector>
#include <map>
#include <nlohmann/json.hpp>
@@ -16,4 +16,3 @@ namespace platform {
void report(json& data);
};
}
#endif //DATASETS_EXCEL_H

View File

@@ -75,6 +75,9 @@ void list_datasets(argparse::ArgumentParser& program)
void list_results(argparse::ArgumentParser& program)
{
std::cout << "Results" << std::endl;
auto dataset = program.get<string>("--dataset");
auto score = program.get<string>("--score");
}
int main(int argc, char** argv)
@@ -107,6 +110,7 @@ int main(int argc, char** argv)
throw std::runtime_error("Dataset must be one of " + datasets.toString());
}
);
program.add_argument("-s", "--score").default_value("accuracy").help("Filter results of the score name supplied");
// Add subparsers
program.add_subparser(datasets_command);
program.add_subparser(results_command);

View File

@@ -1,5 +1,5 @@
#ifndef EXPERIMENT_H
#define EXPERIMENT_H
#pragma once
#include <torch/torch.h>
#include <nlohmann/json.hpp>
#include <string>
@@ -43,4 +43,3 @@ namespace platform {
int max_name{ 7 }; // max length of dataset name for formatting (default 7)
};
}
#endif

View File

@@ -1,5 +1,5 @@
#ifndef HYPERPARAMETERS_H
#define HYPERPARAMETERS_H
#pragma once
#include <string>
#include <map>
#include <vector>
@@ -20,4 +20,3 @@ namespace platform {
std::map<std::string, json> hyperparameters;
};
} /* namespace platform */
#endif /* HYPERPARAMETERS_H */

View File

@@ -1,5 +1,5 @@
#ifndef MODELS_H
#define MODELS_H
#pragma once
#include <map>
#include <bayesnet/BaseClassifier.h>
#include <bayesnet/ensembles/AODE.h>
@@ -39,4 +39,3 @@ namespace platform {
Registrar(const std::string& className, function<bayesnet::BaseClassifier* (void)> classFactoryFunction);
};
}
#endif

View File

@@ -1,5 +1,5 @@
#ifndef RESULT_H
#define RESULT_H
#pragma once
#include <map>
#include <vector>
#include <string>
@@ -48,4 +48,3 @@ namespace platform {
double score = 0.0;
};
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef MODEL_REGISTER_H
#define MODEL_REGISTER_H
#pragma once
static platform::Registrar registrarT("TAN",
[](void) -> bayesnet::BaseClassifier* { return new bayesnet::TAN();});
static platform::Registrar registrarTLD("TANLd",
@@ -28,4 +28,3 @@ static platform::Registrar registrarRaF("RandomForest",
[](void) -> bayesnet::BaseClassifier* { return new pywrap::RandomForest();});
static platform::Registrar registrarXGB("XGBoost",
[](void) -> bayesnet::BaseClassifier* { return new pywrap::XGBoost();});
#endif

View File

@@ -1,5 +1,5 @@
#ifndef COMMAND_PARSER_H
#define COMMAND_PARSER_H
#pragma once
#include <string>
#include <vector>
#include <tuple>
@@ -17,4 +17,3 @@ namespace platform {
int index;
};
} /* namespace platform */
#endif /* COMMAND_PARSER_H */

View File

@@ -12,7 +12,7 @@
namespace platform {
ManageResults::ManageResults(int numFiles, const std::string& model, const std::string& score, bool complete, bool partial, bool compare) :
numFiles{ numFiles }, complete{ complete }, partial{ partial }, compare{ compare }, results(Results(Paths::results(), model, score, complete, partial))
numFiles{ numFiles }, complete{ complete }, partial{ partial }, compare{ compare }, results(ResultsManager(model, score, complete, partial))
{
indexList = true;
openExcel = false;

View File

@@ -1,7 +1,7 @@
#ifndef MANAGE_RESULTS_H
#define MANAGE_RESULTS_H
#pragma once
#include <xlsxwriter.h>
#include "Results.h"
#include "ResultsManager.h"
namespace platform {
class ManageResults {
@@ -23,9 +23,7 @@ namespace platform {
bool complete;
bool partial;
bool compare;
Results results;
ResultsManager results;
lxw_workbook* workbook;
};
}
#endif /* MANAGE_RESULTS_H */

View File

@@ -1,9 +1,10 @@
#include <algorithm>
#include "Results.h"
#include "common/Paths.h"
#include "ResultsManager.h"
namespace platform {
Results::Results(const std::string& path, const std::string& model, const std::string& score, bool complete, bool partial) :
path(path), model(model), scoreName(score), complete(complete), partial(partial)
ResultsManager::ResultsManager(const std::string& model, const std::string& score, bool complete, bool partial) :
path(Paths::results()), model(model), scoreName(score), complete(complete), partial(partial)
{
load();
if (!files.empty()) {
@@ -12,7 +13,7 @@ namespace platform {
maxModel = 0;
}
}
void Results::load()
void ResultsManager::load()
{
using std::filesystem::directory_iterator;
for (const auto& file : directory_iterator(path)) {
@@ -28,47 +29,47 @@ namespace platform {
}
}
}
void Results::hideResult(int index, const std::string& pathHidden)
void ResultsManager::hideResult(int index, const std::string& pathHidden)
{
auto filename = files.at(index).getFilename();
rename((path + "/" + filename).c_str(), (pathHidden + "/" + filename).c_str());
files.erase(files.begin() + index);
}
void Results::deleteResult(int index)
void ResultsManager::deleteResult(int index)
{
auto filename = files.at(index).getFilename();
remove((path + "/" + filename).c_str());
files.erase(files.begin() + index);
}
int Results::size() const
int ResultsManager::size() const
{
return files.size();
}
void Results::sortDate()
void ResultsManager::sortDate()
{
sort(files.begin(), files.end(), [](const Result& a, const Result& b) {
return a.getDate() > b.getDate();
});
}
void Results::sortModel()
void ResultsManager::sortModel()
{
sort(files.begin(), files.end(), [](const Result& a, const Result& b) {
return a.getModel() > b.getModel();
});
}
void Results::sortDuration()
void ResultsManager::sortDuration()
{
sort(files.begin(), files.end(), [](const Result& a, const Result& b) {
return a.getDuration() > b.getDuration();
});
}
void Results::sortScore()
void ResultsManager::sortScore()
{
sort(files.begin(), files.end(), [](const Result& a, const Result& b) {
return a.getScore() > b.getScore();
});
}
bool Results::empty() const
bool ResultsManager::empty() const
{
return files.empty();
}

View File

@@ -1,5 +1,5 @@
#ifndef RESULTS_H
#define RESULTS_H
#pragma once
#include <map>
#include <vector>
#include <string>
@@ -7,9 +7,9 @@
#include "main/Result.h"
namespace platform {
using json = nlohmann::json;
class Results {
class ResultsManager {
public:
Results(const std::string& path, const std::string& model, const std::string& score, bool complete, bool partial);
ResultsManager(const std::string& model, const std::string& score, bool complete, bool partial);
void sortDate();
void sortScore();
void sortModel();
@@ -33,4 +33,3 @@ namespace platform {
void load(); // Loads the list of results
};
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef EXCELFILE_H
#define EXCELFILE_H
#pragma once
#include <locale>
#include <string>
#include <map>
@@ -42,4 +42,3 @@ namespace platform {
void setDefault();
};
}
#endif // !EXCELFILE_H

View File

@@ -1,5 +1,5 @@
#ifndef REPORTBASE_H
#define REPORTBASE_H
#pragma once
#include <string>
#include <iostream>
#include <nlohmann/json.hpp>
@@ -33,4 +33,3 @@ namespace platform {
bool existBestFile = true;
};
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef REPORTCONSOLE_H
#define REPORTCONSOLE_H
#pragma once
#include <string>
#include "common/Colors.h"
#include "ReportBase.h"
@@ -19,4 +19,3 @@ namespace platform {
void showSummary() override;
};
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef REPORTEXCEL_H
#define REPORTEXCEL_H
#pragma once
#include <map>
#include <xlsxwriter.h>
#include "common/Colors.h"
@@ -22,4 +22,3 @@ namespace platform {
void header_notes(int row);
};
};
#endif // !REPORTEXCEL_H

View File

@@ -8,7 +8,7 @@ if(ENABLE_TESTING)
${CMAKE_BINARY_DIR}/configured_files/include
/usr/local/include
)
set(TEST_SOURCES_PLATFORM TestUtils.cc TestPlatform.cc)
set(TEST_SOURCES_PLATFORM TestUtils.cpp TestPlatform.cpp)
add_executable(${TEST_PLATFORM} ${TEST_SOURCES_PLATFORM})
target_link_libraries(${TEST_PLATFORM} PUBLIC "${TORCH_LIBRARIES}" ArffFiles mdlp Catch2::Catch2WithMain)
add_test(NAME ${TEST_PLATFORM} COMMAND ${TEST_PLATFORM})

View File

@@ -1,5 +1,5 @@
#ifndef TEST_UTILS_H
#define TEST_UTILS_H
#pragma once
#include <torch/torch.h>
#include <string>
#include <vector>
@@ -40,4 +40,3 @@ public:
double epsilon = 1e-5;
};
#endif //TEST_UTILS_H