Compare commits
1 Commits
8a02a3a5cb
...
FixSelectF
Author | SHA1 | Date | |
---|---|---|---|
3615a1463c
|
@@ -7,18 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [1.1.1] - 2025-05-08
|
|
||||||
|
|
||||||
### Internal
|
|
||||||
|
|
||||||
- Fix the vcpkg configuration in building the library.
|
|
||||||
- Fix the sample app to use the vcpkg configuration.
|
|
||||||
|
|
||||||
## [1.1.0] - 2025-04-27
|
## [1.1.0] - 2025-04-27
|
||||||
|
|
||||||
### Internal
|
### Internal
|
||||||
|
|
||||||
- Add changes to .clang-format to adjust to vscode format style thanks to <https://clang-format-configurator.site/>
|
- Add changes to .clang-format to ajust to vscode format style thanks to <https://clang-format-configurator.site/>
|
||||||
- Remove all the dependencies as git submodules and add them as vcpkg dependencies.
|
- Remove all the dependencies as git submodules and add them as vcpkg dependencies.
|
||||||
- Fix the dependencies versions for this specific BayesNet version.
|
- Fix the dependencies versions for this specific BayesNet version.
|
||||||
|
|
||||||
|
135
CMakeLists.txt
135
CMakeLists.txt
@@ -1,19 +1,21 @@
|
|||||||
cmake_minimum_required(VERSION 3.27)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(bayesnet
|
project(BayesNet
|
||||||
VERSION 1.1.1
|
VERSION 1.1.0
|
||||||
DESCRIPTION "Bayesian Network and basic classifiers Library."
|
DESCRIPTION "Bayesian Network and basic classifiers Library."
|
||||||
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
|
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
if (CODE_COVERAGE AND NOT ENABLE_TESTING)
|
||||||
cmake_policy(SET CMP0135 NEW)
|
MESSAGE(FATAL_ERROR "Code coverage requires testing enabled")
|
||||||
|
endif (CODE_COVERAGE AND NOT ENABLE_TESTING)
|
||||||
|
|
||||||
find_package(Torch CONFIG REQUIRED)
|
find_package(Torch REQUIRED)
|
||||||
find_package(fimdlp CONFIG REQUIRED)
|
|
||||||
find_package(nlohmann_json CONFIG REQUIRED)
|
if (POLICY CMP0135)
|
||||||
find_package(folding CONFIG REQUIRED)
|
cmake_policy(SET CMP0135 NEW)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Global CMake variables
|
# Global CMake variables
|
||||||
# ----------------------
|
# ----------------------
|
||||||
@@ -31,83 +33,76 @@ endif()
|
|||||||
|
|
||||||
# Options
|
# Options
|
||||||
# -------
|
# -------
|
||||||
option(ENABLE_CLANG_TIDY "Enable to add clang tidy" OFF)
|
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
|
||||||
option(ENABLE_TESTING "Unit testing build" OFF)
|
option(ENABLE_TESTING "Unit testing build" OFF)
|
||||||
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
||||||
option(INSTALL_GTEST "Enable installation of googletest" OFF)
|
option(INSTALL_GTEST "Enable installation of googletest." OFF)
|
||||||
|
|
||||||
add_subdirectory(config)
|
# CMakes modules
|
||||||
|
# --------------
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
MESSAGE("Debug mode")
|
||||||
|
set(ENABLE_TESTING ON)
|
||||||
|
set(CODE_COVERAGE ON)
|
||||||
|
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
|
||||||
|
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||||
|
message(STATUS "Languages=${LANGUAGES}")
|
||||||
|
if (CODE_COVERAGE)
|
||||||
|
enable_testing()
|
||||||
|
include(CodeCoverage)
|
||||||
|
MESSAGE(STATUS "Code coverage enabled")
|
||||||
|
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
||||||
|
endif (CODE_COVERAGE)
|
||||||
|
|
||||||
if (ENABLE_CLANG_TIDY)
|
if (ENABLE_CLANG_TIDY)
|
||||||
include(StaticAnalyzers) # clang-tidy
|
include(StaticAnalyzers) # clang-tidy
|
||||||
endif (ENABLE_CLANG_TIDY)
|
endif (ENABLE_CLANG_TIDY)
|
||||||
|
|
||||||
# Add the library
|
# External libraries - dependencies of BayesNet
|
||||||
# ---------------
|
# ---------------------------------------------
|
||||||
include_directories(
|
|
||||||
${bayesnet_SOURCE_DIR}
|
|
||||||
${CMAKE_BINARY_DIR}/configured_files/include
|
|
||||||
)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE Sources "bayesnet/*.cc")
|
find_package(Torch CONFIG REQUIRED)
|
||||||
|
find_package(fimdlp CONFIG REQUIRED)
|
||||||
|
find_package(nlohmann_json CONFIG REQUIRED)
|
||||||
|
find_package(folding CONFIG REQUIRED)
|
||||||
|
|
||||||
add_library(bayesnet ${Sources})
|
# Subdirectories
|
||||||
target_link_libraries(bayesnet fimdlp::fimdlp folding::folding "${TORCH_LIBRARIES}")
|
# --------------
|
||||||
|
add_subdirectory(config)
|
||||||
|
add_subdirectory(bayesnet)
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
# -------
|
# -------
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
MESSAGE("Debug mode")
|
|
||||||
set(ENABLE_TESTING ON)
|
|
||||||
set(CODE_COVERAGE ON)
|
|
||||||
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
||||||
if (ENABLE_TESTING)
|
if (ENABLE_TESTING)
|
||||||
MESSAGE(STATUS "Testing enabled")
|
MESSAGE(STATUS "Testing enabled")
|
||||||
find_package(Catch2 CONFIG REQUIRED)
|
find_package(Catch2 CONFIG REQUIRED)
|
||||||
find_package(arff-files CONFIG REQUIRED)
|
include(CTest)
|
||||||
enable_testing()
|
add_subdirectory(tests)
|
||||||
include(CTest)
|
|
||||||
add_subdirectory(tests)
|
|
||||||
else(ENABLE_TESTING)
|
|
||||||
message("Release mode")
|
|
||||||
endif (ENABLE_TESTING)
|
endif (ENABLE_TESTING)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
# ------------
|
# ------------
|
||||||
include(CMakePackageConfigHelpers)
|
install(TARGETS BayesNet
|
||||||
write_basic_package_version_file(
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfigVersion.cmake"
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_package_config_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/bayesnetConfig.cmake.in
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfig.cmake"
|
|
||||||
INSTALL_DESTINATION share/bayesnet)
|
|
||||||
|
|
||||||
install(TARGETS bayesnet
|
|
||||||
EXPORT bayesnetTargets
|
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
CONFIGURATIONS Release)
|
CONFIGURATIONS Release)
|
||||||
|
install(DIRECTORY bayesnet/ DESTINATION include/bayesnet FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h")
|
||||||
|
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h DESTINATION include/bayesnet CONFIGURATIONS Release)
|
||||||
|
|
||||||
install(DIRECTORY bayesnet/
|
# Documentation
|
||||||
DESTINATION include/bayesnet
|
# -------------
|
||||||
FILES_MATCHING
|
find_package(Doxygen)
|
||||||
CONFIGURATIONS Release
|
if (Doxygen_FOUND)
|
||||||
PATTERN "*.h")
|
set(DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h
|
set(doxyfile_in ${DOC_DIR}/Doxyfile.in)
|
||||||
DESTINATION include/bayesnet
|
set(doxyfile ${DOC_DIR}/Doxyfile)
|
||||||
CONFIGURATIONS Release)
|
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
|
||||||
|
doxygen_add_docs(doxygen
|
||||||
install(EXPORT bayesnetTargets
|
WORKING_DIRECTORY ${DOC_DIR}
|
||||||
FILE bayesnetTargets.cmake
|
CONFIG_FILE ${doxyfile})
|
||||||
NAMESPACE bayesnet::
|
else (Doxygen_FOUND)
|
||||||
DESTINATION share/bayesnet)
|
MESSAGE("* Doxygen not found")
|
||||||
|
endif (Doxygen_FOUND)
|
||||||
install(FILES
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfig.cmake"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfigVersion.cmake"
|
|
||||||
DESTINATION share/bayesnet
|
|
||||||
)
|
|
||||||
|
11
Makefile
11
Makefile
@@ -5,7 +5,7 @@ SHELL := /bin/bash
|
|||||||
f_release = build_Release
|
f_release = build_Release
|
||||||
f_debug = build_Debug
|
f_debug = build_Debug
|
||||||
f_diagrams = diagrams
|
f_diagrams = diagrams
|
||||||
app_targets = bayesnet
|
app_targets = BayesNet
|
||||||
test_targets = TestBayesNet
|
test_targets = TestBayesNet
|
||||||
clang-uml = clang-uml
|
clang-uml = clang-uml
|
||||||
plantuml = plantuml
|
plantuml = plantuml
|
||||||
@@ -86,13 +86,10 @@ init: ## Initialize the project installing dependencies
|
|||||||
|
|
||||||
clean: ## Clean the project
|
clean: ## Clean the project
|
||||||
@echo ">>> Cleaning the project..."
|
@echo ">>> Cleaning the project..."
|
||||||
|
@if test -d build_Debug ; then echo "- Deleting build_Debug folder" ; rm -rf build_Debug; fi
|
||||||
|
@if test -d build_Release ; then echo "- Deleting build_Release folder" ; rm -rf build_Release; fi
|
||||||
@if test -f CMakeCache.txt ; then echo "- Deleting CMakeCache.txt"; rm -f CMakeCache.txt; fi
|
@if test -f CMakeCache.txt ; then echo "- Deleting CMakeCache.txt"; rm -f CMakeCache.txt; fi
|
||||||
@for folder in $(f_release) $(f_debug) vpcpkg_installed install_test ; do \
|
@if test -d vcpkg_installed ; then echo "- Deleting vcpkg_installed folder" ; rm -rf vcpkg_installed; fi
|
||||||
if test -d "$$folder" ; then \
|
|
||||||
echo "- Deleting $$folder folder" ; \
|
|
||||||
rm -rf "$$folder"; \
|
|
||||||
fi; \
|
|
||||||
done
|
|
||||||
@$(MAKE) clean-test
|
@$(MAKE) clean-test
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
@@ -1,84 +1,141 @@
|
|||||||
// ***************************************************************
|
// **
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
// SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
|
||||||
// SPDX-FileType: SOURCE
|
// SPDX-FileType: SOURCE
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
// ***************************************************************
|
// **
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include "bayesnet/utils/bayesnetUtils.h"
|
#include "bayesnet/utils/bayesnetUtils.h"
|
||||||
#include "FeatureSelect.h"
|
#include "FeatureSelect.h"
|
||||||
namespace bayesnet {
|
|
||||||
FeatureSelect::FeatureSelect(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int maxFeatures, const int classNumStates, const torch::Tensor& weights) :
|
|
||||||
Metrics(samples, features, className, classNumStates), maxFeatures(maxFeatures == 0 ? samples.size(0) - 1 : maxFeatures), weights(weights)
|
|
||||||
|
|
||||||
|
namespace bayesnet {
|
||||||
|
|
||||||
|
using namespace torch::indexing; // for Ellipsis constant
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// ctor
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
FeatureSelect::FeatureSelect(const torch::Tensor& samples,
|
||||||
|
const std::vector<std::string>& features,
|
||||||
|
const std::string& className,
|
||||||
|
int maxFeatures,
|
||||||
|
int classNumStates,
|
||||||
|
const torch::Tensor& weights)
|
||||||
|
: Metrics(samples, features, className, classNumStates),
|
||||||
|
maxFeatures(maxFeatures == 0 ? samples.size(0) - 1 : maxFeatures),
|
||||||
|
weights(weights)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// public helpers
|
||||||
|
//---------------------------------------------------------------------
|
||||||
void FeatureSelect::initialize()
|
void FeatureSelect::initialize()
|
||||||
{
|
{
|
||||||
selectedFeatures.clear();
|
selectedFeatures.clear();
|
||||||
selectedScores.clear();
|
selectedScores.clear();
|
||||||
|
suLabels.clear();
|
||||||
|
suFeatures.clear();
|
||||||
|
|
||||||
|
fitted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Symmetrical Uncertainty (SU)
|
||||||
|
//---------------------------------------------------------------------
|
||||||
double FeatureSelect::symmetricalUncertainty(int a, int b)
|
double FeatureSelect::symmetricalUncertainty(int a, int b)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Compute symmetrical uncertainty. Normalize* information gain (mutual
|
* Compute symmetrical uncertainty. Normalises the information gain
|
||||||
information) with the entropies of the features in order to compensate
|
* (mutual information) with the entropies of the variables to compensate
|
||||||
the bias due to high cardinality features. *Range [0, 1]
|
* the bias due to high‑cardinality features. Range: [0, 1]
|
||||||
(https://www.sciencedirect.com/science/article/pii/S0020025519303603)
|
* See: https://www.sciencedirect.com/science/article/pii/S0020025519303603
|
||||||
*/
|
*/
|
||||||
auto x = samples.index({ a, "..." });
|
|
||||||
auto y = samples.index({ b, "..." });
|
auto x = samples.index({ a, Ellipsis }); // row a => feature a
|
||||||
auto mu = mutualInformation(x, y, weights);
|
auto y = (b >= 0) ? samples.index({ b, Ellipsis }) // row b (>=0) => feature b
|
||||||
auto hx = entropy(x, weights);
|
: samples.index({ -1, Ellipsis }); // ‑1 treated as last row = labels
|
||||||
auto hy = entropy(y, weights);
|
|
||||||
return 2.0 * mu / (hx + hy);
|
double mu = mutualInformation(x, y, weights);
|
||||||
|
double hx = entropy(x, weights);
|
||||||
|
double hy = entropy(y, weights);
|
||||||
|
|
||||||
|
const double denom = hx + hy;
|
||||||
|
if (denom == 0.0) return 0.0; // perfectly pure variables
|
||||||
|
|
||||||
|
return 2.0 * mu / denom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// SU feature–class
|
||||||
|
//---------------------------------------------------------------------
|
||||||
void FeatureSelect::computeSuLabels()
|
void FeatureSelect::computeSuLabels()
|
||||||
{
|
{
|
||||||
// Compute Simmetrical Uncertainty between features and labels
|
// Compute Symmetrical Uncertainty between each feature and the class labels
|
||||||
// https://en.wikipedia.org/wiki/Symmetric_uncertainty
|
// https://en.wikipedia.org/wiki/Symmetric_uncertainty
|
||||||
for (int i = 0; i < features.size(); ++i) {
|
const int classIdx = static_cast<int>(samples.size(0)) - 1; // labels in last row
|
||||||
suLabels.push_back(symmetricalUncertainty(i, -1));
|
suLabels.reserve(features.size());
|
||||||
|
for (int i = 0; i < static_cast<int>(features.size()); ++i) {
|
||||||
|
suLabels.emplace_back(symmetricalUncertainty(i, classIdx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double FeatureSelect::computeSuFeatures(const int firstFeature, const int secondFeature)
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// SU feature–feature with cache
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
double FeatureSelect::computeSuFeatures(int firstFeature, int secondFeature)
|
||||||
{
|
{
|
||||||
// Compute Simmetrical Uncertainty between features
|
// Order the pair to exploit symmetry => only one entry in the map
|
||||||
// https://en.wikipedia.org/wiki/Symmetric_uncertainty
|
auto ordered = std::minmax(firstFeature, secondFeature);
|
||||||
try {
|
const std::pair<int, int> key{ ordered.first, ordered.second };
|
||||||
return suFeatures.at({ firstFeature, secondFeature });
|
|
||||||
}
|
auto it = suFeatures.find(key);
|
||||||
catch (const std::out_of_range& e) {
|
if (it != suFeatures.end()) return it->second;
|
||||||
double result = symmetricalUncertainty(firstFeature, secondFeature);
|
|
||||||
suFeatures[{firstFeature, secondFeature}] = result;
|
double result = symmetricalUncertainty(key.first, key.second);
|
||||||
return result;
|
suFeatures[key] = result; // store once (symmetry handled by ordering)
|
||||||
}
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Correlation‑based Feature Selection (CFS) merit
|
||||||
|
//---------------------------------------------------------------------
|
||||||
double FeatureSelect::computeMeritCFS()
|
double FeatureSelect::computeMeritCFS()
|
||||||
{
|
{
|
||||||
double rcf = 0;
|
const int n = static_cast<int>(selectedFeatures.size());
|
||||||
for (auto feature : selectedFeatures) {
|
if (n == 0) return 0.0;
|
||||||
rcf += suLabels[feature];
|
|
||||||
}
|
// average r_cf (feature–class)
|
||||||
double rff = 0;
|
double rcf_sum = 0.0;
|
||||||
int n = selectedFeatures.size();
|
for (int f : selectedFeatures) rcf_sum += suLabels[f];
|
||||||
for (const auto& item : doCombinations(selectedFeatures)) {
|
const double rcf_avg = rcf_sum / n;
|
||||||
rff += computeSuFeatures(item.first, item.second);
|
|
||||||
}
|
// average r_ff (feature–feature)
|
||||||
return rcf / sqrt(n + (n * n - n) * rff);
|
double rff_sum = 0.0;
|
||||||
|
const auto& pairs = doCombinations(selectedFeatures); // generates each unordered pair once
|
||||||
|
for (const auto& p : pairs) rff_sum += computeSuFeatures(p.first, p.second);
|
||||||
|
|
||||||
|
const double numPairs = n * (n - 1) * 0.5;
|
||||||
|
const double rff_avg = (numPairs > 0) ? rff_sum / numPairs : 0.0;
|
||||||
|
|
||||||
|
// Merit_S = k * r_cf / sqrt( k + k*(k‑1) * r_ff ) (Hall, 1999)
|
||||||
|
const double k = static_cast<double>(n);
|
||||||
|
return (k * rcf_avg) / std::sqrt(k + k * (k - 1) * rff_avg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// getters
|
||||||
|
//---------------------------------------------------------------------
|
||||||
std::vector<int> FeatureSelect::getFeatures() const
|
std::vector<int> FeatureSelect::getFeatures() const
|
||||||
{
|
{
|
||||||
if (!fitted) {
|
if (!fitted) throw std::runtime_error("FeatureSelect not fitted");
|
||||||
throw std::runtime_error("FeatureSelect not fitted");
|
|
||||||
}
|
|
||||||
return selectedFeatures;
|
return selectedFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> FeatureSelect::getScores() const
|
std::vector<double> FeatureSelect::getScores() const
|
||||||
{
|
{
|
||||||
if (!fitted) {
|
if (!fitted) throw std::runtime_error("FeatureSelect not fitted");
|
||||||
throw std::runtime_error("FeatureSelect not fitted");
|
|
||||||
}
|
|
||||||
return selectedScores;
|
return selectedScores;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // namespace bayesnet
|
||||||
|
|
@@ -1,4 +0,0 @@
|
|||||||
@PACKAGE_INIT@
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/bayesnetTargets.cmake")
|
|
||||||
|
|
@@ -11,4 +11,4 @@ static constexpr std::string_view project_name = "@PROJECT_NAME@";
|
|||||||
static constexpr std::string_view project_version = "@PROJECT_VERSION@";
|
static constexpr std::string_view project_version = "@PROJECT_VERSION@";
|
||||||
static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";
|
static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";
|
||||||
static constexpr std::string_view git_sha = "@GIT_SHA@";
|
static constexpr std::string_view git_sha = "@GIT_SHA@";
|
||||||
static constexpr std::string_view data_path = "@bayesnet_SOURCE_DIR@/tests/data/";
|
static constexpr std::string_view data_path = "@BayesNet_SOURCE_DIR@/tests/data/";
|
1
lib/catch2
Submodule
1
lib/catch2
Submodule
Submodule lib/catch2 added at 029fe3b460
1
lib/folding
Submodule
1
lib/folding
Submodule
Submodule lib/folding added at 2ac43e32ac
1
lib/json
Submodule
1
lib/json
Submodule
Submodule lib/json added at 620034ecec
1
lib/mdlp
Submodule
1
lib/mdlp
Submodule
Submodule lib/mdlp added at 7d62d6af4a
@@ -1,16 +1,15 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(bayesnet_sample VERSION 0.1.0 LANGUAGES CXX)
|
project(bayesnet_sample)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
|
||||||
|
|
||||||
find_package(Torch CONFIG REQUIRED)
|
find_package(Torch CONFIG REQUIRED)
|
||||||
|
find_package(bayesnet CONFIG REQUIRED)
|
||||||
find_package(fimdlp CONFIG REQUIRED)
|
find_package(fimdlp CONFIG REQUIRED)
|
||||||
find_package(folding CONFIG REQUIRED)
|
find_package(folding CONFIG REQUIRED)
|
||||||
find_package(arff-files CONFIG REQUIRED)
|
find_package(arff-files CONFIG REQUIRED)
|
||||||
find_package(bayesnet CONFIG REQUIRED)
|
find_package(nlohman_json CONFIG REQUIRED)
|
||||||
|
|
||||||
add_executable(bayesnet_sample sample.cc)
|
add_executable(bayesnet_sample sample.cc)
|
||||||
target_link_libraries(bayesnet_sample PRIVATE
|
target_link_libraries(bayesnet_sample PRIVATE
|
||||||
@@ -18,5 +17,6 @@ target_link_libraries(bayesnet_sample PRIVATE
|
|||||||
arff-files::arff-files
|
arff-files::arff-files
|
||||||
"${TORCH_LIBRARIES}"
|
"${TORCH_LIBRARIES}"
|
||||||
bayesnet::bayesnet
|
bayesnet::bayesnet
|
||||||
|
nlohmann_json::nlohmann_json
|
||||||
folding::folding
|
folding::folding
|
||||||
)
|
)
|
||||||
|
@@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"default-registry": {
|
|
||||||
"kind": "git",
|
|
||||||
"baseline": "760bfd0c8d7c89ec640aec4df89418b7c2745605",
|
|
||||||
"repository": "https://github.com/microsoft/vcpkg"
|
|
||||||
},
|
|
||||||
"registries": [
|
"registries": [
|
||||||
{
|
{
|
||||||
"kind": "git",
|
"kind": "git",
|
||||||
"repository": "https://github.com/rmontanana/vcpkg-stash",
|
"repository": "https://github.com/rmontanana/vcpkg-stash",
|
||||||
"baseline": "1ea69243c0e8b0de77c9d1dd6e1d7593ae7f3627",
|
"baseline": "393efa4e74e053b6f02c4ab03738c8fe796b28e5",
|
||||||
"packages": [
|
"packages": [
|
||||||
"arff-files",
|
|
||||||
"bayesnet",
|
|
||||||
"fimdlp",
|
|
||||||
"folding",
|
"folding",
|
||||||
|
"bayesnet",
|
||||||
|
"arff-files",
|
||||||
|
"fimdlp",
|
||||||
"libtorch-bin"
|
"libtorch-bin"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"default-registry": {
|
||||||
|
"kind": "git",
|
||||||
|
"repository": "https://github.com/microsoft/vcpkg",
|
||||||
|
"baseline": "760bfd0c8d7c89ec640aec4df89418b7c2745605"
|
||||||
|
}
|
||||||
}
|
}
|
@@ -2,32 +2,11 @@
|
|||||||
"name": "sample-project",
|
"name": "sample-project",
|
||||||
"version-string": "0.1.0",
|
"version-string": "0.1.0",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
"bayesnet",
|
||||||
|
"folding",
|
||||||
"arff-files",
|
"arff-files",
|
||||||
"fimdlp",
|
"fimdlp",
|
||||||
"libtorch-bin",
|
"nlohmann-json",
|
||||||
"folding",
|
"libtorch-bin"
|
||||||
"bayesnet"
|
|
||||||
],
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"name": "arff-files",
|
|
||||||
"version": "1.1.0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "fimdlp",
|
|
||||||
"version": "2.0.1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "libtorch-bin",
|
|
||||||
"version": "2.7.0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "bayesnet",
|
|
||||||
"version": "1.1.1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "folding",
|
|
||||||
"version": "1.1.1"
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
@@ -1,13 +1,18 @@
|
|||||||
if(ENABLE_TESTING)
|
if(ENABLE_TESTING)
|
||||||
include_directories(
|
include_directories(
|
||||||
|
${BayesNet_SOURCE_DIR}/tests/lib/Files
|
||||||
|
${BayesNet_SOURCE_DIR}/lib/folding
|
||||||
|
${BayesNet_SOURCE_DIR}/lib/mdlp/src
|
||||||
|
${BayesNet_SOURCE_DIR}/lib/log
|
||||||
|
${BayesNet_SOURCE_DIR}/lib/json/include
|
||||||
${BayesNet_SOURCE_DIR}
|
${BayesNet_SOURCE_DIR}
|
||||||
${CMAKE_BINARY_DIR}/configured_files/include
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
)
|
)
|
||||||
file(GLOB_RECURSE BayesNet_SOURCES "${bayesnet_SOURCE_DIR}/bayesnet/*.cc")
|
file(GLOB_RECURSE BayesNet_SOURCES "${BayesNet_SOURCE_DIR}/bayesnet/*.cc")
|
||||||
add_executable(TestBayesNet TestBayesNetwork.cc TestBayesNode.cc TestBayesClassifier.cc TestXSPnDE.cc TestXBA2DE.cc
|
add_executable(TestBayesNet TestBayesNetwork.cc TestBayesNode.cc TestBayesClassifier.cc TestXSPnDE.cc TestXBA2DE.cc
|
||||||
TestBayesModels.cc TestBayesMetrics.cc TestFeatureSelection.cc TestBoostAODE.cc TestXBAODE.cc TestA2DE.cc
|
TestBayesModels.cc TestBayesMetrics.cc TestFeatureSelection.cc TestBoostAODE.cc TestXBAODE.cc TestA2DE.cc
|
||||||
TestUtils.cc TestBayesEnsemble.cc TestModulesVersions.cc TestBoostA2DE.cc TestMST.cc TestXSPODE.cc ${BayesNet_SOURCES})
|
TestUtils.cc TestBayesEnsemble.cc TestModulesVersions.cc TestBoostA2DE.cc TestMST.cc TestXSPODE.cc ${BayesNet_SOURCES})
|
||||||
target_link_libraries(TestBayesNet PUBLIC "${TORCH_LIBRARIES}" fimdlp::fimdlp PRIVATE Catch2::Catch2WithMain)
|
target_link_libraries(TestBayesNet PUBLIC "${TORCH_LIBRARIES}" fimdlp PRIVATE Catch2::Catch2WithMain)
|
||||||
add_test(NAME BayesNetworkTest COMMAND TestBayesNet)
|
add_test(NAME BayesNetworkTest COMMAND TestBayesNet)
|
||||||
add_test(NAME A2DE COMMAND TestBayesNet "[A2DE]")
|
add_test(NAME A2DE COMMAND TestBayesNet "[A2DE]")
|
||||||
add_test(NAME BoostA2DE COMMAND TestBayesNet "[BoostA2DE]")
|
add_test(NAME BoostA2DE COMMAND TestBayesNet "[BoostA2DE]")
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include "bayesnet/ensembles/AODELd.h"
|
#include "bayesnet/ensembles/AODELd.h"
|
||||||
#include "bayesnet/ensembles/BoostAODE.h"
|
#include "bayesnet/ensembles/BoostAODE.h"
|
||||||
|
|
||||||
const std::string ACTUAL_VERSION = "1.1.1";
|
const std::string ACTUAL_VERSION = "1.1.0";
|
||||||
|
|
||||||
TEST_CASE("Test Bayesian Classifiers score & version", "[Models]")
|
TEST_CASE("Test Bayesian Classifiers score & version", "[Models]")
|
||||||
{
|
{
|
||||||
|
1
tests/lib/Files
Submodule
1
tests/lib/Files
Submodule
Submodule tests/lib/Files added at a4329f5f9d
1
tests/lib/catch2
Submodule
1
tests/lib/catch2
Submodule
Submodule tests/lib/catch2 added at 506276c592
@@ -8,7 +8,7 @@
|
|||||||
{
|
{
|
||||||
"kind": "git",
|
"kind": "git",
|
||||||
"repository": "https://github.com/rmontanana/vcpkg-stash",
|
"repository": "https://github.com/rmontanana/vcpkg-stash",
|
||||||
"baseline": "1ea69243c0e8b0de77c9d1dd6e1d7593ae7f3627",
|
"baseline": "393efa4e74e053b6f02c4ab03738c8fe796b28e5",
|
||||||
"packages": [
|
"packages": [
|
||||||
"arff-files",
|
"arff-files",
|
||||||
"fimdlp",
|
"fimdlp",
|
||||||
|
Reference in New Issue
Block a user