diff --git a/Makefile b/Makefile index 2d3c9c1..0886104 100644 --- a/Makefile +++ b/Makefile @@ -49,10 +49,10 @@ dependency: ## Create a dependency graph diagram of the project (build/dependenc cd $(f_debug) && cmake .. --graphviz=dependency.dot && dot -Tpng dependency.dot -o dependency.png buildd: ## Build the debug targets - cmake --build $(f_debug) -t $(app_targets) $(n_procs) + cmake --build $(f_debug) -t $(app_targets) BayesNetSample $(n_procs) buildr: ## Build the release targets - cmake --build $(f_release) -t $(app_targets) $(n_procs) + cmake --build $(f_release) -t $(app_targets) BayesNetSample $(n_procs) clean: ## Clean the tests info @echo ">>> Cleaning Debug BayesNet tests..."; diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index 4a41a72..38b9e3d 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -1,8 +1,10 @@ include_directories(${BayesNet_SOURCE_DIR}/src/Platform) include_directories(${BayesNet_SOURCE_DIR}/src/BayesNet) +include_directories(${BayesNet_SOURCE_DIR}/src/PyClassifiers) +include_directories(${Python3_INCLUDE_DIRS}) include_directories(${BayesNet_SOURCE_DIR}/lib/Files) include_directories(${BayesNet_SOURCE_DIR}/lib/mdlp) include_directories(${BayesNet_SOURCE_DIR}/lib/argparse/include) include_directories(${BayesNet_SOURCE_DIR}/lib/json/include) add_executable(BayesNetSample sample.cc ${BayesNet_SOURCE_DIR}/src/Platform/Folding.cc ${BayesNet_SOURCE_DIR}/src/Platform/Models.cc) -target_link_libraries(BayesNetSample BayesNet ArffFiles mdlp "${TORCH_LIBRARIES}") \ No newline at end of file +target_link_libraries(BayesNetSample BayesNet ArffFiles mdlp "${TORCH_LIBRARIES}" PyWrap) \ No newline at end of file diff --git a/sample/sample.cc b/sample/sample.cc index 8024707..9a19e79 100644 --- a/sample/sample.cc +++ b/sample/sample.cc @@ -29,7 +29,7 @@ pair, map> discretize(std::vector< return { Xd, maxes }; } -bool file_exists(const std::std::std::string& name) +bool file_exists(const std::string& name) { if (FILE* file = fopen(name.c_str(), "r")) { fclose(file); @@ -72,7 +72,7 @@ int main(int argc, char** argv) argparse::ArgumentParser program("BayesNetSample"); program.add_argument("-d", "--dataset") .help("Dataset file name") - .action([valid_datasets](const std::std::std::string& value) { + .action([valid_datasets](const std::string& value) { if (find(valid_datasets.begin(), valid_datasets.end(), value) != valid_datasets.end()) { return value; } @@ -84,20 +84,20 @@ int main(int argc, char** argv) .default_value(std::string{ PATH } ); program.add_argument("-m", "--model") - .help("Model to use " + platform::Models::instance()->tostd::string()) - .action([](const std::std::std::string& value) { + .help("Model to use " + platform::Models::instance()->tostring()) + .action([](const std::string& value) { static const std::vector choices = platform::Models::instance()->getNames(); if (find(choices.begin(), choices.end(), value) != choices.end()) { return value; } - throw runtime_error("Model must be one of " + platform::Models::instance()->tostd::string()); + throw runtime_error("Model must be one of " + platform::Models::instance()->tostring()); } ); program.add_argument("--discretize").help("Discretize input dataset").default_value(false).implicit_value(true); program.add_argument("--dumpcpt").help("Dump CPT Tables").default_value(false).implicit_value(true); program.add_argument("--stratified").help("If Stratified KFold is to be done").default_value(false).implicit_value(true); program.add_argument("--tensors").help("Use tensors to store samples").default_value(false).implicit_value(true); - program.add_argument("-f", "--folds").help("Number of folds").default_value(5).scan<'i', int>().action([](const std::std::string& value) { + program.add_argument("-f", "--folds").help("Number of folds").default_value(5).scan<'i', int>().action([](const std::string& value) { try { auto k = stoi(value); if (k < 2) { @@ -184,8 +184,8 @@ int main(int argc, char** argv) file.close(); std::cout << "Graph saved in " << model_name << "_" << file_name << ".dot" << std::endl; std::cout << "dot -Tpng -o " + dot_file + ".png " + dot_file + ".dot " << std::endl; - std::string stratified_std::string = stratified ? " Stratified" : ""; - std::cout << nFolds << " Folds" << stratified_std::string << " Cross validation" << std::endl; + std::string stratified_string = stratified ? " Stratified" : ""; + std::cout << nFolds << " Folds" << stratified_string << " Cross validation" << std::endl; std::cout << "==========================================" << std::endl; torch::Tensor Xt = torch::zeros({ static_cast(Xd.size()), static_cast(Xd[0].size()) }, torch::kInt32); torch::Tensor yt = torch::tensor(y, torch::kInt32);