aGrUM  0.16.0
DBRowGeneratorEM.h
Go to the documentation of this file.
1 
28 #ifndef GUM_LEARNING_DBROW_GENERATOR_EM_H
29 #define GUM_LEARNING_DBROW_GENERATOR_EM_H
30 
31 #include <vector>
32 
33 #include <agrum/agrum.h>
34 #include <agrum/core/bijection.h>
35 #include <agrum/BN/BayesNet.h>
38 
39 namespace gum {
40 
41  namespace learning {
42 
79  template < typename GUM_SCALAR = double,
80  template < typename > class ALLOC = std::allocator >
81  class DBRowGeneratorEM : public DBRowGeneratorWithBN< GUM_SCALAR, ALLOC > {
82  public:
84  using allocator_type = ALLOC< DBTranslatedValue >;
85 
86  // ##########################################################################
88  // ##########################################################################
89 
91 
94  const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > >
95  column_types,
96  const BayesNet< GUM_SCALAR >& bn,
97  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
98  nodeId2columns =
99  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
100  const allocator_type& alloc = allocator_type());
101 
104 
107  const allocator_type& alloc);
108 
111 
114  const allocator_type& alloc);
115 
117  virtual DBRowGeneratorEM< GUM_SCALAR, ALLOC >* clone() const override final;
118 
120  virtual DBRowGeneratorEM< GUM_SCALAR, ALLOC >*
121  clone(const allocator_type& alloc) const override final;
122 
124  ~DBRowGeneratorEM();
125 
127 
128 
129  // ##########################################################################
131  // ##########################################################################
132 
134 
136  DBRowGeneratorEM< GUM_SCALAR, ALLOC >&
137  operator=(const DBRowGeneratorEM< GUM_SCALAR, ALLOC >& from);
138 
140  DBRowGeneratorEM< GUM_SCALAR, ALLOC >&
141  operator=(DBRowGeneratorEM< GUM_SCALAR, ALLOC >&& from);
142 
144 
145 
146  // ##########################################################################
148  // ##########################################################################
149 
151 
153  virtual const DBRow< DBTranslatedValue, ALLOC >& generate() override final;
154 
156  virtual void
157  setBayesNet(const BayesNet< GUM_SCALAR >& new_bn) override final;
158 
161 
163 
164 
165  protected:
167  virtual std::size_t
168  _computeRows(const DBRow< DBTranslatedValue, ALLOC >& row) override final;
169 
170 
171 #ifndef DOXYGEN_SHOULD_SKIP_THIS
172 
173  private:
175  const DBRow< DBTranslatedValue, ALLOC >* __input_row{nullptr};
176 
178  std::vector< std::size_t, ALLOC< std::size_t > > __missing_cols;
179 
181  std::size_t __nb_miss;
182 
184  Potential< GUM_SCALAR > __joint_proba;
185 
187  Instantiation* __joint_inst{nullptr};
188 
190 
196  DBRow< DBTranslatedValue, ALLOC > __filled_row1;
197 
199  DBRow< DBTranslatedValue, ALLOC > __filled_row2;
200 
202  bool __use_filled_row1{true};
203 
205  double __original_weight;
206 
207 
208 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
209  };
210 
211  } /* namespace learning */
212 
213 } /* namespace gum */
214 
215 
216 // always include the template implementation
218 
219 #endif /* GUM_LEARNING_DBROW_GENERATOR_EM_H */
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:60
Class representing a Bayesian Network.
Definition: BayesNet.h:78
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
DBRowGeneratorEM(const std::vector< DBTranslatedValueType, ALLOC< DBTranslatedValueType > > column_types, const BayesNet< GUM_SCALAR > &bn, const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &nodeId2columns=Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(), const allocator_type &alloc=allocator_type())
default constructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
STL namespace.
A DBRowGenerator class that returns incomplete rows as EM would do.
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
The union class for storing the translated values in learning databases.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual DBRowGeneratorEM< GUM_SCALAR, ALLOC > * clone() const override final
virtual copy constructor
DBTranslatedValueType
The nature of the elements handled by translators (discrete, continuous).
Base class for DBRowGenerator classes that use a BN for computing their outputs.
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
virtual void setBayesNet(const BayesNet< GUM_SCALAR > &new_bn) override final
assign a new Bayes net to the generator
The class for storing a record in a database.
Definition: DBRow.h:56
virtual std::size_t _computeRows(const DBRow< DBTranslatedValue, ALLOC > &row) override final
computes the rows it will provide as output
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
virtual const DBRow< DBTranslatedValue, ALLOC > & generate() override final
generates one ouput DBRow for each DBRow passed to method setInputRow
Size NodeId
Type for node ids.
Definition: graphElements.h:98
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
allocator_type getAllocator() const
returns the allocator used
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods