Compare commits

..

3 Commits

6 changed files with 289 additions and 151 deletions

View File

@@ -50,120 +50,115 @@ namespace bayesnet {
// loguru::g_stderr_verbosity = loguru::Verbosity_OFF; // loguru::g_stderr_verbosity = loguru::Verbosity_OFF;
// loguru::add_file("boostA2DE.log", loguru::Truncate, loguru::Verbosity_MAX); // loguru::add_file("boostA2DE.log", loguru::Truncate, loguru::Verbosity_MAX);
// // Algorithm based on the adaboost algorithm for classification // Algorithm based on the adaboost algorithm for classification
// // as explained in Ensemble methods (Zhi-Hua Zhou, 2012) // as explained in Ensemble methods (Zhi-Hua Zhou, 2012)
// fitted = true; fitted = true;
// double alpha_t = 0; double alpha_t = 0;
// torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64); torch::Tensor weights_ = torch::full({ m }, 1.0 / m, torch::kFloat64);
// bool finished = false; bool finished = false;
// std::vector<int> featuresUsed; std::vector<int> featuresUsed;
// if (selectFeatures) { if (selectFeatures) {
// featuresUsed = initializeModels(); featuresUsed = initializeModels();
// auto ypred = predict(X_train); auto ypred = predict(X_train);
// std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_); std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
// // Update significance of the models // Update significance of the models
// for (int i = 0; i < n_models; ++i) { for (int i = 0; i < n_models; ++i) {
// significanceModels[i] = alpha_t; significanceModels[i] = alpha_t;
// } }
// if (finished) { if (finished) {
// return; return;
// } }
// } }
// int numItemsPack = 0; // The counter of the models inserted in the current pack int numItemsPack = 0; // The counter of the models inserted in the current pack
// // Variables to control the accuracy finish condition // Variables to control the accuracy finish condition
// double priorAccuracy = 0.0; double priorAccuracy = 0.0;
// double improvement = 1.0; double improvement = 1.0;
// double convergence_threshold = 1e-4; double convergence_threshold = 1e-4;
// int tolerance = 0; // number of times the accuracy is lower than the convergence_threshold int tolerance = 0; // number of times the accuracy is lower than the convergence_threshold
// // Step 0: Set the finish condition // Step 0: Set the finish condition
// // epsilon sub t > 0.5 => inverse the weights policy // epsilon sub t > 0.5 => inverse the weights policy
// // validation error is not decreasing // validation error is not decreasing
// // run out of features // run out of features
// bool ascending = order_algorithm == Orders.ASC; bool ascending = order_algorithm == Orders.ASC;
// std::mt19937 g{ 173 }; std::mt19937 g{ 173 };
// while (!finished) { std::vector<std::pair<int, int>> pairSelection;
// // Step 1: Build ranking with mutual information while (!finished) {
// auto pairSelection = metrics.SelectKBestWeighted(weights_, ascending, n); // Get all the features sorted // Step 1: Build ranking with mutual information
// if (order_algorithm == Orders.RAND) { pairSelection = metrics.SelectKPairs(weights_, featuresUsed, ascending, 0); // Get all the pairs sorted
// std::shuffle(featureSelection.begin(), featureSelection.end(), g); if (order_algorithm == Orders.RAND) {
// } std::shuffle(pairSelection.begin(), pairSelection.end(), g);
// // Remove used features }
// featureSelection.erase(remove_if(begin(featureSelection), end(featureSelection), [&](auto x) int k = bisection ? pow(2, tolerance) : 1;
// { return std::find(begin(featuresUsed), end(featuresUsed), x) != end(featuresUsed);}), int counter = 0; // The model counter of the current pack
// end(featureSelection) // VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size());
// ); while (counter++ < k && pairSelection.size() > 0) {
// int k = bisection ? pow(2, tolerance) : 1; auto feature_pair = pairSelection[0];
// int counter = 0; // The model counter of the current pack pairSelection.erase(pairSelection.begin());
// VLOG_SCOPE_F(1, "counter=%d k=%d featureSelection.size: %zu", counter, k, featureSelection.size()); std::unique_ptr<Classifier> model;
// while (counter++ < k && featureSelection.size() > 0) { model = std::make_unique<SPnDE>(std::vector<int>({ feature_pair.first, feature_pair.second }));
// auto feature = featureSelection[0]; model->fit(dataset, features, className, states, weights_);
// featureSelection.erase(featureSelection.begin()); alpha_t = 0.0;
// std::unique_ptr<Classifier> model; if (!block_update) {
// model = std::make_unique<SPODE>(feature); auto ypred = model->predict(X_train);
// model->fit(dataset, features, className, states, weights_); // Step 3.1: Compute the classifier amout of say
// alpha_t = 0.0; std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_);
// if (!block_update) { }
// auto ypred = model->predict(X_train); // Step 3.4: Store classifier and its accuracy to weigh its future vote
// // Step 3.1: Compute the classifier amout of say numItemsPack++;
// std::tie(weights_, alpha_t, finished) = update_weights(y_train, ypred, weights_); models.push_back(std::move(model));
// } significanceModels.push_back(alpha_t);
// // Step 3.4: Store classifier and its accuracy to weigh its future vote n_models++;
// numItemsPack++; // VLOG_SCOPE_F(2, "numItemsPack: %d n_models: %d featuresUsed: %zu", numItemsPack, n_models, featuresUsed.size());
// featuresUsed.push_back(feature); }
// models.push_back(std::move(model)); if (block_update) {
// significanceModels.push_back(alpha_t); std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_);
// n_models++; }
// VLOG_SCOPE_F(2, "numItemsPack: %d n_models: %d featuresUsed: %zu", numItemsPack, n_models, featuresUsed.size()); if (convergence && !finished) {
// } auto y_val_predict = predict(X_test);
// if (block_update) { double accuracy = (y_val_predict == y_test).sum().item<double>() / (double)y_test.size(0);
// std::tie(weights_, alpha_t, finished) = update_weights_block(k, y_train, weights_); if (priorAccuracy == 0) {
// } priorAccuracy = accuracy;
// if (convergence && !finished) { } else {
// auto y_val_predict = predict(X_test); improvement = accuracy - priorAccuracy;
// double accuracy = (y_val_predict == y_test).sum().item<double>() / (double)y_test.size(0); }
// if (priorAccuracy == 0) { if (improvement < convergence_threshold) {
// priorAccuracy = accuracy; // VLOG_SCOPE_F(3, " (improvement<threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
// } else { tolerance++;
// improvement = accuracy - priorAccuracy; } else {
// } // VLOG_SCOPE_F(3, "* (improvement>=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy);
// if (improvement < convergence_threshold) { tolerance = 0; // Reset the counter if the model performs better
// VLOG_SCOPE_F(3, " (improvement<threshold) tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy); numItemsPack = 0;
// tolerance++; }
// } else { if (convergence_best) {
// VLOG_SCOPE_F(3, "* (improvement>=threshold) Reset. tolerance: %d numItemsPack: %d improvement: %f prior: %f current: %f", tolerance, numItemsPack, improvement, priorAccuracy, accuracy); // Keep the best accuracy until now as the prior accuracy
// tolerance = 0; // Reset the counter if the model performs better priorAccuracy = std::max(accuracy, priorAccuracy);
// numItemsPack = 0; } else {
// } // Keep the last accuray obtained as the prior accuracy
// if (convergence_best) { priorAccuracy = accuracy;
// // Keep the best accuracy until now as the prior accuracy }
// priorAccuracy = std::max(accuracy, priorAccuracy); }
// } else { // VLOG_SCOPE_F(1, "tolerance: %d featuresUsed.size: %zu features.size: %zu", tolerance, featuresUsed.size(), features.size());
// // Keep the last accuray obtained as the prior accuracy finished = finished || tolerance > maxTolerance || pairSelection.size() == 0;
// priorAccuracy = accuracy; }
// } if (tolerance > maxTolerance) {
// } if (numItemsPack < n_models) {
// VLOG_SCOPE_F(1, "tolerance: %d featuresUsed.size: %zu features.size: %zu", tolerance, featuresUsed.size(), features.size()); notes.push_back("Convergence threshold reached & " + std::to_string(numItemsPack) + " models eliminated");
// finished = finished || tolerance > maxTolerance || featuresUsed.size() == features.size(); // VLOG_SCOPE_F(4, "Convergence threshold reached & %d models eliminated of %d", numItemsPack, n_models);
// } for (int i = 0; i < numItemsPack; ++i) {
// if (tolerance > maxTolerance) { significanceModels.pop_back();
// if (numItemsPack < n_models) { models.pop_back();
// notes.push_back("Convergence threshold reached & " + std::to_string(numItemsPack) + " models eliminated"); n_models--;
// VLOG_SCOPE_F(4, "Convergence threshold reached & %d models eliminated of %d", numItemsPack, n_models); }
// for (int i = 0; i < numItemsPack; ++i) { } else {
// significanceModels.pop_back(); notes.push_back("Convergence threshold reached & 0 models eliminated");
// models.pop_back(); // VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack);
// n_models--; }
// } }
// } else { if (pairSelection.size() > 0) {
// notes.push_back("Convergence threshold reached & 0 models eliminated"); notes.push_back("Used pairs not used in train: " + std::to_string(pairSelection.size()));
// VLOG_SCOPE_F(4, "Convergence threshold reached & 0 models eliminated n_models=%d numItemsPack=%d", n_models, numItemsPack); status = WARNING;
// } }
// } notes.push_back("Number of models: " + std::to_string(n_models));
// if (featuresUsed.size() != features.size()) {
// notes.push_back("Used features in train: " + std::to_string(featuresUsed.size()) + " of " + std::to_string(features.size()));
// status = WARNING;
// }
// notes.push_back("Number of models: " + std::to_string(n_models));
} }
std::vector<std::string> BoostA2DE::graph(const std::string& title) const std::vector<std::string> BoostA2DE::graph(const std::string& title) const
{ {

View File

@@ -30,42 +30,51 @@ namespace bayesnet {
} }
samples.index_put_({ -1, "..." }, torch::tensor(labels, torch::kInt32)); samples.index_put_({ -1, "..." }, torch::tensor(labels, torch::kInt32));
} }
std::vector<std::pair<int, int>> Metrics::SelectKPairs(const torch::Tensor& weights, bool ascending, unsigned k) std::vector<std::pair<int, int>> Metrics::SelectKPairs(const torch::Tensor& weights, std::vector<int>& featuresExcluded, bool ascending, unsigned k)
{ {
// Return the K Best features // Return the K Best features
auto n = features.size(); auto n = features.size();
if (k == 0) {
k = n;
}
// compute scores // compute scores
scoresKPairs.clear(); scoresKPairs.clear();
pairsKBest.clear(); pairsKBest.clear();
auto label = samples.index({ -1, "..." }); auto labels = samples.index({ -1, "..." });
// for (int i = 0; i < n; ++i) { for (int i = 0; i < n - 1; ++i) {
// for (int j = i + 1; j < n; ++j) { if (std::find(featuresExcluded.begin(), featuresExcluded.end(), i) != featuresExcluded.end()) {
// scoresKBest.push_back(mutualInformation(samples.index({ i, "..." }), samples.index({ j, "..." }), weights)); continue;
// featuresKBest.push_back(i); }
// featuresKBest.push_back(j); for (int j = i + 1; j < n; ++j) {
// } if (std::find(featuresExcluded.begin(), featuresExcluded.end(), j) != featuresExcluded.end()) {
// } continue;
// // sort & reduce scores and features }
// if (ascending) { auto key = std::make_pair(i, j);
// sort(featuresKBest.begin(), featuresKBest.end(), [&](int i, int j) auto value = conditionalMutualInformation(samples.index({ i, "..." }), samples.index({ j, "..." }), labels, weights);
// { return scoresKBest[i] < scoresKBest[j]; }); scoresKPairs.push_back({ key, value });
// sort(scoresKBest.begin(), scoresKBest.end(), std::less<double>()); }
// if (k < n) { }
// for (int i = 0; i < n - k; ++i) { // sort scores
// featuresKBest.erase(featuresKBest.begin()); if (ascending) {
// scoresKBest.erase(scoresKBest.begin()); sort(scoresKPairs.begin(), scoresKPairs.end(), [](auto& a, auto& b)
// } { return a.second < b.second; });
// }
// } else { } else {
// sort(featuresKBest.begin(), featuresKBest.end(), [&](int i, int j) sort(scoresKPairs.begin(), scoresKPairs.end(), [](auto& a, auto& b)
// { return scoresKBest[i] > scoresKBest[j]; }); { return a.second > b.second; });
// sort(scoresKBest.begin(), scoresKBest.end(), std::greater<double>()); }
// featuresKBest.resize(k); for (auto& [pairs, score] : scoresKPairs) {
// scoresKBest.resize(k); pairsKBest.push_back(pairs);
// } }
if (k != 0 && k < pairsKBest.size()) {
if (ascending) {
int limit = pairsKBest.size() - k;
for (int i = 0; i < limit; i++) {
pairsKBest.erase(pairsKBest.begin());
scoresKPairs.erase(scoresKPairs.begin());
}
} else {
pairsKBest.resize(k);
scoresKPairs.resize(k);
}
}
return pairsKBest; return pairsKBest;
} }
std::vector<int> Metrics::SelectKBestWeighted(const torch::Tensor& weights, bool ascending, unsigned k) std::vector<int> Metrics::SelectKBestWeighted(const torch::Tensor& weights, bool ascending, unsigned k)
@@ -107,7 +116,10 @@ namespace bayesnet {
{ {
return scoresKBest; return scoresKBest;
} }
std::vector<std::pair<std::pair<int, int>, double>> Metrics::getScoresKPairs() const
{
return scoresKPairs;
}
torch::Tensor Metrics::conditionalEdge(const torch::Tensor& weights) torch::Tensor Metrics::conditionalEdge(const torch::Tensor& weights)
{ {
auto result = std::vector<double>(); auto result = std::vector<double>();

View File

@@ -16,8 +16,9 @@ namespace bayesnet {
Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates); Metrics(const torch::Tensor& samples, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
Metrics(const std::vector<std::vector<int>>& vsamples, const std::vector<int>& labels, const std::vector<std::string>& features, const std::string& className, const int classNumStates); Metrics(const std::vector<std::vector<int>>& vsamples, const std::vector<int>& labels, const std::vector<std::string>& features, const std::string& className, const int classNumStates);
std::vector<int> SelectKBestWeighted(const torch::Tensor& weights, bool ascending = false, unsigned k = 0); std::vector<int> SelectKBestWeighted(const torch::Tensor& weights, bool ascending = false, unsigned k = 0);
std::vector<std::pair<int, int>> SelectKPairs(const torch::Tensor& weights, bool ascending = false, unsigned k = 0); std::vector<std::pair<int, int>> SelectKPairs(const torch::Tensor& weights, std::vector<int>& featuresExcluded, bool ascending = false, unsigned k = 0);
std::vector<double> getScoresKBest() const; std::vector<double> getScoresKBest() const;
std::vector<std::pair<std::pair<int, int>, double>> getScoresKPairs() const;
double mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights); double mutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
double conditionalMutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights); double conditionalMutualInformation(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& labels, const torch::Tensor& weights);
torch::Tensor conditionalEdge(const torch::Tensor& weights); torch::Tensor conditionalEdge(const torch::Tensor& weights);
@@ -34,7 +35,7 @@ namespace bayesnet {
std::vector<std::pair<T, T>> doCombinations(const std::vector<T>& source) std::vector<std::pair<T, T>> doCombinations(const std::vector<T>& source)
{ {
std::vector<std::pair<T, T>> result; std::vector<std::pair<T, T>> result;
for (int i = 0; i < source.size(); ++i) { for (int i = 0; i < source.size() - 1; ++i) {
T temp = source[i]; T temp = source[i];
for (int j = i + 1; j < source.size(); ++j) { for (int j = i + 1; j < source.size(); ++j) {
result.push_back({ temp, source[j] }); result.push_back({ temp, source[j] });
@@ -42,7 +43,7 @@ namespace bayesnet {
} }
return result; return result;
} }
template <class T> template <class T>
T pop_first(std::vector<T>& v) T pop_first(std::vector<T>& v)
{ {
T temp = v[0]; T temp = v[0];
@@ -54,7 +55,7 @@ namespace bayesnet {
std::vector<double> scoresKBest; std::vector<double> scoresKBest;
std::vector<int> featuresKBest; // sorted indices of the features std::vector<int> featuresKBest; // sorted indices of the features
std::vector<std::pair<int, int>> pairsKBest; // sorted indices of the pairs std::vector<std::pair<int, int>> pairsKBest; // sorted indices of the pairs
std::map<std::pair<int, int>, double> scoresKPairs; std::vector<std::pair<std::pair<int, int>, double>> scoresKPairs;
double conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights); double conditionalEntropy(const torch::Tensor& firstFeature, const torch::Tensor& secondFeature, const torch::Tensor& weights);
}; };
} }

View File

@@ -137,3 +137,132 @@ TEST_CASE("Conditional Mutual Information", "[Metrics]")
} }
} }
} }
TEST_CASE("Select K Pairs descending", "[Metrics]")
{
auto raw = RawDatasets("iris", true);
bayesnet::Metrics metrics(raw.dataset, raw.features, raw.className, raw.classNumStates);
std::vector<int> empty;
auto results = metrics.SelectKPairs(raw.weights, empty, false);
auto expected = std::vector<std::pair<std::pair<int, int>, double>>{
{ { 1, 3 }, 1.31852 },
{ { 1, 2 }, 1.17112 },
{ { 0, 3 }, 0.403749 },
{ { 0, 2 }, 0.287696 },
{ { 2, 3 }, 0.210068 },
{ { 0, 1 }, 0.0 },
};
auto scores = metrics.getScoresKPairs();
for (int i = 0; i < results.size(); ++i) {
auto result = results[i];
auto expect = expected[i];
auto score = scores[i];
REQUIRE(result.first == expect.first.first);
REQUIRE(result.second == expect.first.second);
REQUIRE(score.first.first == expect.first.first);
REQUIRE(score.first.second == expect.first.second);
REQUIRE(score.second == Catch::Approx(expect.second).epsilon(raw.epsilon));
}
REQUIRE(results.size() == 6);
REQUIRE(scores.size() == 6);
}
TEST_CASE("Select K Pairs ascending", "[Metrics]")
{
auto raw = RawDatasets("iris", true);
bayesnet::Metrics metrics(raw.dataset, raw.features, raw.className, raw.classNumStates);
std::vector<int> empty;
auto results = metrics.SelectKPairs(raw.weights, empty, true);
auto expected = std::vector<std::pair<std::pair<int, int>, double>>{
{ { 0, 1 }, 0.0 },
{ { 2, 3 }, 0.210068 },
{ { 0, 2 }, 0.287696 },
{ { 0, 3 }, 0.403749 },
{ { 1, 2 }, 1.17112 },
{ { 1, 3 }, 1.31852 },
};
auto scores = metrics.getScoresKPairs();
for (int i = 0; i < results.size(); ++i) {
auto result = results[i];
auto expect = expected[i];
auto score = scores[i];
REQUIRE(result.first == expect.first.first);
REQUIRE(result.second == expect.first.second);
REQUIRE(score.first.first == expect.first.first);
REQUIRE(score.first.second == expect.first.second);
REQUIRE(score.second == Catch::Approx(expect.second).epsilon(raw.epsilon));
}
REQUIRE(results.size() == 6);
REQUIRE(scores.size() == 6);
}
TEST_CASE("Select K Pairs with features excluded", "[Metrics]")
{
auto raw = RawDatasets("iris", true);
bayesnet::Metrics metrics(raw.dataset, raw.features, raw.className, raw.classNumStates);
std::vector<int> excluded = { 0, 3 };
auto results = metrics.SelectKPairs(raw.weights, excluded, true);
auto expected = std::vector<std::pair<std::pair<int, int>, double>>{
{ { 1, 2 }, 1.17112 },
};
auto scores = metrics.getScoresKPairs();
for (int i = 0; i < results.size(); ++i) {
auto result = results[i];
auto expect = expected[i];
auto score = scores[i];
REQUIRE(result.first == expect.first.first);
REQUIRE(result.second == expect.first.second);
REQUIRE(score.first.first == expect.first.first);
REQUIRE(score.first.second == expect.first.second);
REQUIRE(score.second == Catch::Approx(expect.second).epsilon(raw.epsilon));
}
REQUIRE(results.size() == 1);
REQUIRE(scores.size() == 1);
}
TEST_CASE("Select K Pairs with number of pairs descending", "[Metrics]")
{
auto raw = RawDatasets("iris", true);
bayesnet::Metrics metrics(raw.dataset, raw.features, raw.className, raw.classNumStates);
std::vector<int> empty;
auto results = metrics.SelectKPairs(raw.weights, empty, false, 3);
auto expected = std::vector<std::pair<std::pair<int, int>, double>>{
{ { 1, 3 }, 1.31852 },
{ { 1, 2 }, 1.17112 },
{ { 0, 3 }, 0.403749 }
};
auto scores = metrics.getScoresKPairs();
REQUIRE(results.size() == 3);
REQUIRE(scores.size() == 3);
for (int i = 0; i < results.size(); ++i) {
auto result = results[i];
auto expect = expected[i];
auto score = scores[i];
REQUIRE(result.first == expect.first.first);
REQUIRE(result.second == expect.first.second);
REQUIRE(score.first.first == expect.first.first);
REQUIRE(score.first.second == expect.first.second);
REQUIRE(score.second == Catch::Approx(expect.second).epsilon(raw.epsilon));
}
}
TEST_CASE("Select K Pairs with number of pairs ascending", "[Metrics]")
{
auto raw = RawDatasets("iris", true);
bayesnet::Metrics metrics(raw.dataset, raw.features, raw.className, raw.classNumStates);
std::vector<int> empty;
auto results = metrics.SelectKPairs(raw.weights, empty, true, 3);
auto expected = std::vector<std::pair<std::pair<int, int>, double>>{
{ { 0, 3 }, 0.403749 },
{ { 1, 2 }, 1.17112 },
{ { 1, 3 }, 1.31852 }
};
auto scores = metrics.getScoresKPairs();
REQUIRE(results.size() == 3);
REQUIRE(scores.size() == 3);
for (int i = 0; i < results.size(); ++i) {
auto result = results[i];
auto expect = expected[i];
auto score = scores[i];
REQUIRE(result.first == expect.first.first);
REQUIRE(result.second == expect.first.second);
REQUIRE(score.first.first == expect.first.first);
REQUIRE(score.first.second == expect.first.second);
REQUIRE(score.second == Catch::Approx(expect.second).epsilon(raw.epsilon));
}
}

View File

@@ -56,14 +56,14 @@ TEST_CASE("Test Bayesian Classifiers score & version", "[Models]")
auto raw = RawDatasets(file_name, discretize); auto raw = RawDatasets(file_name, discretize);
clf->fit(raw.Xt, raw.yt, raw.features, raw.className, raw.states); clf->fit(raw.Xt, raw.yt, raw.features, raw.className, raw.states);
auto score = clf->score(raw.Xt, raw.yt); auto score = clf->score(raw.Xt, raw.yt);
INFO("Classifier: " + name + " File: " + file_name); INFO("Classifier: " << name << " File: " << file_name);
REQUIRE(score == Catch::Approx(scores[{file_name, name}]).epsilon(raw.epsilon)); REQUIRE(score == Catch::Approx(scores[{file_name, name}]).epsilon(raw.epsilon));
REQUIRE(clf->getStatus() == bayesnet::NORMAL); REQUIRE(clf->getStatus() == bayesnet::NORMAL);
} }
} }
SECTION("Library check version") SECTION("Library check version")
{ {
INFO("Checking version of " + name + " classifier"); INFO("Checking version of " << name << " classifier");
REQUIRE(clf->getVersion() == ACTUAL_VERSION); REQUIRE(clf->getVersion() == ACTUAL_VERSION);
} }
delete clf; delete clf;

View File

@@ -8,6 +8,7 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/catch_approx.hpp> #include <catch2/catch_approx.hpp>
#include <catch2/generators/catch_generators.hpp> #include <catch2/generators/catch_generators.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include "bayesnet/ensembles/BoostAODE.h" #include "bayesnet/ensembles/BoostAODE.h"
#include "TestUtils.h" #include "TestUtils.h"