Begin Fix Test MST
This commit is contained in:
parent
8c3864f3c8
commit
fe5fead27e
33
mac_mst.txt
Normal file
33
mac_mst.txt
Normal file
@ -0,0 +1,33 @@
|
||||
Weights matrix:
|
||||
0.0000000, 0.0384968, 0.0795434, 0.1546867, -0.0000000, 0.1788104, 0.2214721, 0.0323837, 0.0366549,
|
||||
0.0384968, 0.0000000, 0.0200662, 0.0200937, -0.0000000, 0.0637224, 0.0183005, 0.0127657, 0.0136054,
|
||||
0.0795434, 0.0200662, 0.0000000, 0.0605489, -0.0000000, 0.0894469, 0.1689408, 0.0321602, 0.0223184,
|
||||
0.1546867, 0.0200937, 0.0605489, 0.0000000, -0.0000000, 0.1150757, 0.1332292, 0.0422865, 0.0191138,
|
||||
-0.0000000, -0.0000000, -0.0000000, -0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000,
|
||||
0.1788104, 0.0637224, 0.0894469, 0.1150757, 0.0000000, 0.0000000, 0.1407102, 0.0406590, 0.0366986,
|
||||
0.2214721, 0.0183005, 0.1689408, 0.1332292, 0.0000000, 0.1407102, 0.0000000, 0.0427515, 0.0349965,
|
||||
0.0323837, 0.0127657, 0.0321602, 0.0422865, 0.0000000, 0.0406590, 0.0427515, 0.0000000, 0.0343376,
|
||||
0.0366549, 0.0136054, 0.0223184, 0.0191138, 0.0000000, 0.0366986, 0.0349965, 0.0343376, 0.0000000,
|
||||
Edge : Weight
|
||||
0 - 6 : 0.2214721
|
||||
0 - 5 : 0.1788104
|
||||
2 - 6 : 0.1689408
|
||||
0 - 3 : 0.1546867
|
||||
1 - 5 : 0.0637224
|
||||
6 - 7 : 0.0427515
|
||||
5 - 8 : 0.0366986
|
||||
4 - 5 : 0.0000000
|
||||
-------------------------------------------------------------------------------
|
||||
Metrics Test
|
||||
Test Maximum Spanning Tree
|
||||
-------------------------------------------------------------------------------
|
||||
/Users/rmontanana/Code/BayesNet/tests/TestBayesMetrics.cc:58
|
||||
...............................................................................
|
||||
|
||||
/Users/rmontanana/Code/BayesNet/tests/TestBayesMetrics.cc:69: PASSED:
|
||||
REQUIRE( result == resultsMST.at(file_name) )
|
||||
with expansion:
|
||||
(0, 6) (0, 5) (0, 3) (5, 1) (5, 8) (5, 4) (6, 2) (6, 7)
|
||||
==
|
||||
(0, 6) (0, 5) (0, 3) (5, 1) (5, 8) (5, 4) (6, 2) (6, 7)
|
||||
|
@ -108,6 +108,7 @@ namespace bayesnet {
|
||||
}
|
||||
g.kruskal_algorithm();
|
||||
auto mst = g.get_mst();
|
||||
g.display_mst();
|
||||
return reorder(mst, root);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,13 @@ using namespace std;
|
||||
|
||||
TEST_CASE("Metrics Test", "[BayesNet]")
|
||||
{
|
||||
string file_name = GENERATE("glass", "iris", "ecoli", "diabetes");
|
||||
// string file_name = GENERATE("glass", "iris", "ecoli", "diabetes");
|
||||
string file_name = "glass";
|
||||
//
|
||||
//
|
||||
// OJO CAMBIAR
|
||||
//
|
||||
//
|
||||
map<string, pair<int, vector<int>>> resultsKBest = {
|
||||
{"glass", {7, { 0, 1, 7, 6, 3, 5, 2 }}},
|
||||
{"iris", {3, { 0, 3, 2 }} },
|
||||
@ -52,6 +58,13 @@ TEST_CASE("Metrics Test", "[BayesNet]")
|
||||
SECTION("Test Maximum Spanning Tree")
|
||||
{
|
||||
auto weights_matrix = metrics.conditionalEdge(raw.weights);
|
||||
cout << "Weights matrix: " << endl;
|
||||
for (int i = 0; i < static_cast<int>(raw.featurest.size()); ++i) {
|
||||
for (int j = 0; j < static_cast<int>(raw.featurest.size()); ++j) {
|
||||
cout << setw(10) << setprecision(7) << fixed << weights_matrix[i][j].item<float>() << ", ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
auto result = metrics.maximumSpanningTree(raw.featurest, weights_matrix, 0);
|
||||
REQUIRE(result == resultsMST.at(file_name));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user