MCPcopy Create free account
hub / github.com/davisking/dlib / bayes_nets_test

Function bayes_nets_test

dlib/test/bayes_nets.cpp:219–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217
218
219 void bayes_nets_test (
220 )
221 /*!
222 ensures
223 - runs tests on the bayesian network objects and functions for compliance with the specs
224 !*/
225 {
226
227 print_spinner();
228
229 directed_graph<bayes_node>::kernel_1a_c bn;
230 setup_dyspnea_network(bn);
231
232 using namespace bayes_node_utils;
233
234
235 graph<dlib::set<unsigned long>::compare_1b_c, dlib::set<unsigned long>::compare_1b_c>::kernel_1a_c join_tree;
236
237 create_moral_graph(bn, join_tree);
238 create_join_tree(join_tree, join_tree);
239
240 bayesian_network_join_tree solution(bn, join_tree);
241
242 matrix<double,1,2> dist;
243
244 dist = solution.probability(A);
245 DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
246 DLIB_TEST(abs(dist(1) - 0.01 ) < 1e-5);
247
248 dist = solution.probability(T);
249 DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
250 DLIB_TEST(abs(dist(1) - 0.0104) < 1e-5);
251
252 dist = solution.probability(O);
253 DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
254 DLIB_TEST(abs(dist(1) - 0.064828) < 1e-5);
255
256 dist = solution.probability(X);
257 DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
258 DLIB_TEST(abs(dist(1) - 0.11029004) < 1e-5);
259
260 dist = solution.probability(L);
261 DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
262 DLIB_TEST(abs(dist(1) - 0.055) < 1e-5);
263
264 dist = solution.probability(S);
265 DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
266 DLIB_TEST(abs(dist(1) - 0.5) < 1e-5);
267
268 dist = solution.probability(B);
269 DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
270 DLIB_TEST(abs(dist(1) - 0.4499999) < 1e-5);
271
272 dist = solution.probability(D);
273 DLIB_TEST(abs(sum(dist) - 1.0) < 1e-5);
274 DLIB_TEST(abs(dist(1) - 0.4359706 ) < 1e-5);
275
276 // now lets modify the probabilities of the bayesian network by making O

Callers 1

perform_testMethod · 0.85

Calls 15

print_spinnerFunction · 0.85
setup_dyspnea_networkFunction · 0.85
create_moral_graphFunction · 0.85
create_join_treeFunction · 0.85
absFunction · 0.85
distFunction · 0.85
set_node_valueFunction · 0.85
set_node_as_evidenceFunction · 0.85
set_all_elementsFunction · 0.85
node_valueFunction · 0.85
setup_simple_networkFunction · 0.85
sample_graphMethod · 0.80

Tested by

no test coverage detected