aGrUM  0.16.0
K2_tpl.h
Go to the documentation of this file.
1 
29 #include <type_traits>
30 
34 
35 namespace gum {
36 
37  namespace learning {
38 
40  template < typename GRAPH_CHANGES_SELECTOR >
41  DAG K2::learnStructure(GRAPH_CHANGES_SELECTOR& selector, DAG initial_dag) {
42  // check that we used a selector compatible with the K2 algorithm
43  static_assert(
44  std::is_base_of< __GraphChangesGenerator4K2,
45  typename GRAPH_CHANGES_SELECTOR::GeneratorType >::value,
46  "K2 must be called with a K2-compliant Graph Change Generator");
47 
48  // check that the order passed in argument concerns all the nodes
49  //__checkOrder(modal);
50 
51  // get the generator and assign the order
52  auto& generator = selector.graphChangeGenerator();
53  generator.setOrder(__order);
54 
55  // use the greedy hill climbing algorithm to perform the search
56  return GreedyHillClimbing::learnStructure(selector, initial_dag);
57  }
58 
60  template < typename GUM_SCALAR,
61  typename GRAPH_CHANGES_SELECTOR,
62  typename PARAM_ESTIMATOR >
63  BayesNet< GUM_SCALAR > K2::learnBN(GRAPH_CHANGES_SELECTOR& selector,
64  PARAM_ESTIMATOR& estimator,
65  DAG initial_dag) {
66  // check that we used a selector compatible with the K2 algorithm
67  static_assert(
68  std::is_base_of< __GraphChangesGenerator4K2,
69  typename GRAPH_CHANGES_SELECTOR::GeneratorType >::value,
70  "K2 must be called with a K2-compliant Graph Change Generator");
71 
72  // check that the order passed in argument concerns all the nodes
73  //__checkOrder(modal);
74 
75  // get the generator and assign the order
76  auto& generator = selector.graphChangeGenerator();
77  generator.setOrder(__order);
78 
79  // use the greedy hill climbing algorithm to perform the search
80  return GreedyHillClimbing::learnBN< GUM_SCALAR >(
81  selector, estimator, initial_dag);
82  }
83 
84  } /* namespace learning */
85 
86 } /* namespace gum */
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Class representing a Bayesian Network.
Definition: BayesNet.h:78
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
Definition: K2_tpl.h:41
Base class for dag.
Definition: DAG.h:102
Sequence< NodeId > __order
the order on the variable used for learning
Definition: K2.h:119
BayesNet< GUM_SCALAR > learnBN(GRAPH_CHANGES_SELECTOR &selector, PARAM_ESTIMATOR &estimator, DAG initial_dag=DAG())
learns the structure and the parameters of a BN
Definition: K2_tpl.h:63