From e55365c41cec7dcdf8615d9b8159a58022caa64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Tue, 2 Apr 2024 17:56:23 +0200 Subject: [PATCH] Update test Models --- .vscode/c_cpp_properties.json | 3 ++- tests/TestBayesModels.cc | 40 +++++++++++++++++------------------ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 07aeaac..2619c62 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -27,7 +27,8 @@ "name": "Linux", "includePath": [ "/home/rmontanana/Code/BayesNet/**", - "/home/rmontanana/Code/libtorch/include/torch/csrc/api/include/" + "/home/rmontanana/Code/libtorch/include/torch/csrc/api/include/", + "/home/rmontanana/Code/BayesNet/lib/" ], "defines": [], "cStandard": "c17", diff --git a/tests/TestBayesModels.cc b/tests/TestBayesModels.cc index 517b00a..3ca1bc0 100644 --- a/tests/TestBayesModels.cc +++ b/tests/TestBayesModels.cc @@ -98,26 +98,26 @@ TEST_CASE("BoostAODE feature_select CFS", "[Models]") REQUIRE(clf.getNotes()[0] == "Used features in initialization: 6 of 9 with CFS"); REQUIRE(clf.getNotes()[1] == "Number of models: 9"); } -// TEST_CASE("BoostAODE test used features in train note and score", "[BayesNet]") -// { -// auto raw = RawDatasets("diabetes", true); -// auto clf = bayesnet::BoostAODE(true); -// clf.setHyperparameters({ -// {"order", "asc"}, -// {"convergence", true}, -// {"select_features","CFS"}, -// }); -// clf.fit(raw.Xv, raw.yv, raw.featuresv, raw.classNamev, raw.statesv); -// REQUIRE(clf.getNumberOfNodes() == 72); -// REQUIRE(clf.getNumberOfEdges() == 120); -// REQUIRE(clf.getNotes().size() == 2); -// REQUIRE(clf.getNotes()[0] == "Used features in initialization: 7 of 8 with CFS"); -// REQUIRE(clf.getNotes()[1] == "Number of models: 8"); -// auto score = clf.score(raw.Xv, raw.yv); -// auto scoret = clf.score(raw.Xt, raw.yt); -// REQUIRE(score == Catch::Approx(0.82031).epsilon(raw.epsilon)); -// REQUIRE(scoret == Catch::Approx(0.82031).epsilon(raw.epsilon)); -// } +TEST_CASE("BoostAODE test used features in train note and score", "[Models]") +{ + auto raw = RawDatasets("diabetes", true); + auto clf = bayesnet::BoostAODE(true); + clf.setHyperparameters({ + {"order", "asc"}, + {"convergence", true}, + {"select_features","CFS"}, + }); + clf.fit(raw.Xv, raw.yv, raw.featuresv, raw.classNamev, raw.statesv); + REQUIRE(clf.getNumberOfNodes() == 72); + REQUIRE(clf.getNumberOfEdges() == 120); + REQUIRE(clf.getNotes().size() == 2); + REQUIRE(clf.getNotes()[0] == "Used features in initialization: 6 of 8 with CFS"); + REQUIRE(clf.getNotes()[1] == "Number of models: 8"); + auto score = clf.score(raw.Xv, raw.yv); + auto scoret = clf.score(raw.Xt, raw.yt); + REQUIRE(score == Catch::Approx(0.82031).epsilon(raw.epsilon)); + REQUIRE(scoret == Catch::Approx(0.82031).epsilon(raw.epsilon)); +} TEST_CASE("Model predict_proba", "[Models]") { std::string model = GENERATE("TAN", "SPODE", "BoostAODEproba", "BoostAODEvoting");