aGrUM  0.16.0
K2.h
Go to the documentation of this file.
1 
28 #ifndef GUM_LEARNING_K2_H
29 #define GUM_LEARNING_K2_H
30 
31 #include <string>
32 #include <vector>
33 
34 #include <agrum/BN/BayesNet.h>
35 #include <agrum/core/sequence.h>
36 #include <agrum/graphs/DAG.h>
38 
39 namespace gum {
40 
41  namespace learning {
42 
47  class K2 : private GreedyHillClimbing {
48  public:
49  // ##########################################################################
51  // ##########################################################################
53 
55  K2();
56 
58  K2(const K2& from);
59 
61  K2(K2&& from);
62 
64  ~K2();
65 
67 
68  // ##########################################################################
70  // ##########################################################################
72 
74  K2& operator=(const K2& from);
75 
77  K2& operator=(K2&& from);
78 
80 
81  // ##########################################################################
83  // ##########################################################################
85 
88 
90  void setOrder(const Sequence< NodeId >& order);
91 
93  void setOrder(const std::vector< NodeId >& order);
94 
96  const Sequence< NodeId >& order() const noexcept;
97 
99 
105  template < typename GRAPH_CHANGES_SELECTOR >
106  DAG learnStructure(GRAPH_CHANGES_SELECTOR& selector,
107  DAG initial_dag = DAG());
108 
110  template < typename GUM_SCALAR,
111  typename GRAPH_CHANGES_SELECTOR,
112  typename PARAM_ESTIMATOR >
113  BayesNet< GUM_SCALAR > learnBN(GRAPH_CHANGES_SELECTOR& selector,
114  PARAM_ESTIMATOR& estimator,
115  DAG initial_dag = DAG());
116 
117  private:
120 
124  void __checkOrder(const std::vector< Size >& modal);
126  };
127 
128  } /* namespace learning */
129 
130 } /* namespace gum */
131 
133 #ifndef GUM_NO_INLINE
134 # include <agrum/learning/K2_inl.h>
135 #endif /* GUM_NO_INLINE */
136 
138 #include <agrum/learning/K2_tpl.h>
139 
140 #endif /* GUM_LEARNING_K2_H */
Class representing a Bayesian Network.
Definition: BayesNet.h:78
ApproximationScheme & approximationScheme()
returns the approximation policy of the learning algorithm
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Approximation Scheme.
void setOrder(const Sequence< NodeId > &order)
sets the order on the variables
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
const Sequence< NodeId > & order() const noexcept
returns the current order
The greedy hill climbing learning algorithm (for directed graphs)
K2 & operator=(const K2 &from)
copy operator
K2()
default constructor
DAG learnStructure(GRAPH_CHANGES_SELECTOR &selector, DAG initial_dag=DAG())
learns the structure of a Bayes net
Definition: K2_tpl.h:41
The K2 algorithm.
Definition: K2.h:47
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __checkOrder(const std::vector< Size > &modal)
checks that the order passed to K2 is coherent with the variables as specified by their modalities ...
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.
Base class for dag.
Definition: DAG.h:102
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
~K2()
destructor
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