Update tests to last version

This commit is contained in:
2024-03-06 18:04:34 +01:00
parent c8826fc3b4
commit 101fb02da5
3 changed files with 8 additions and 2 deletions

View File

@@ -2,10 +2,12 @@ include_directories(
${PyClassifiers_SOURCE_DIR}/lib/Files ${PyClassifiers_SOURCE_DIR}/lib/Files
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/lib/json/include ${PyClassifiers_SOURCE_DIR}/lib/BayesNet/lib/json/include
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src ${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src/classifiers
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src/bayesian_network
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src/utils
${CMAKE_BINARY_DIR}/configured_files/include ${CMAKE_BINARY_DIR}/configured_files/include
${Python3_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS}
${TORCH_INCLUDE_DIRS} ${TORCH_INCLUDE_DIRS}
) )
add_library(PyClassifiers SHARED ${PyClassifiers_SOURCES}) add_library(PyClassifiers SHARED ${PyClassifiers_SOURCES})
#target_link_libraries(PyClassifiers ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy xgboost::xgboost)
target_link_libraries(PyClassifiers BayesNet ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy) target_link_libraries(PyClassifiers BayesNet ${Python3_LIBRARIES} "${TORCH_LIBRARIES}" ${LIBTORCH_PYTHON} Boost::boost Boost::python Boost::numpy)

View File

@@ -6,6 +6,9 @@ if(ENABLE_TESTING)
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/lib/Files ${PyClassifiers_SOURCE_DIR}/lib/BayesNet/lib/Files
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/lib/mdlp ${PyClassifiers_SOURCE_DIR}/lib/BayesNet/lib/mdlp
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src ${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src/classifiers
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src/bayesian_network
${PyClassifiers_SOURCE_DIR}/lib/BayesNet/src/utils
${Python3_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS}
${TORCH_INCLUDE_DIRS} ${TORCH_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/configured_files/include ${CMAKE_BINARY_DIR}/configured_files/include

View File

@@ -35,11 +35,12 @@ TEST_CASE("Test Python Classifiers score", "[PyClassifiers]")
}; };
SECTION("Test Python Classifier " + name + " score ") SECTION("Test Python Classifier " + name + " score ")
{ {
for (auto file_name : { "glass", "iris", "ecoli", "diabetes" }) { for (std::string file_name : { "glass", "iris", "ecoli", "diabetes" }) {
auto raw = RawDatasets(file_name, false); auto raw = RawDatasets(file_name, false);
auto clf = models[name]; auto clf = models[name];
clf->fit(raw.Xt, raw.yt, raw.featurest, raw.classNamet, raw.statest); clf->fit(raw.Xt, raw.yt, raw.featurest, raw.classNamet, raw.statest);
auto score = clf->score(raw.Xt, raw.yt); auto score = clf->score(raw.Xt, raw.yt);
INFO("File: " + file_name + " Classifier: " + name + " Score: " + to_string(score));
REQUIRE(score == Catch::Approx(scores[{file_name, name}]).epsilon(raw.epsilon)); REQUIRE(score == Catch::Approx(scores[{file_name, name}]).epsilon(raw.epsilon));
} }
} }