aGrUM  0.16.0
aprioriDirichletFromDatabase.h
Go to the documentation of this file.
1 
28 #ifndef GUM_LEARNING_A_PRIORI_DIRICHLET_FROM_DATABASE_H
29 #define GUM_LEARNING_A_PRIORI_DIRICHLET_FROM_DATABASE_H
30 
31 #include <vector>
32 
33 #include <agrum/agrum.h>
36 
37 namespace gum {
38 
39  namespace learning {
40 
46  template < template < typename > class ALLOC = std::allocator >
47  class AprioriDirichletFromDatabase : public Apriori< ALLOC > {
48  public:
51 
53  using allocator_type = ALLOC< NodeId >;
54 
55 
56  // ##########################################################################
58  // ##########################################################################
60 
62 
82  const DatabaseTable< ALLOC >& learning_db,
83  const DBRowGeneratorParser< ALLOC >& apriori_parser,
84  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
85  nodeId2columns =
86  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
87  const allocator_type& alloc = allocator_type());
88 
92 
96  const allocator_type& alloc);
97 
100 
103  const allocator_type& alloc);
104 
107 
110  clone(const allocator_type& alloc) const;
111 
114 
116 
117 
118  // ##########################################################################
120  // ##########################################################################
122 
126 
130 
132 
133 
134  // ##########################################################################
136  // ##########################################################################
138 
140  virtual bool isOfType(const std::string& type) final;
141 
143  virtual const std::string& getType() const final;
144 
146 
153  virtual bool isInformative() const final;
154 
156  virtual void setWeight(const double weight) final;
157 
159 
164  virtual void
165  addAllApriori(const IdSet< ALLOC >& idset,
166  std::vector< double, ALLOC< double > >& counts) final;
167 
173  virtual void addConditioningApriori(
174  const IdSet< ALLOC >& idset,
175  std::vector< double, ALLOC< double > >& counts) final;
176 
178 
179 
180 #ifndef DOXYGEN_SHOULD_SKIP_THIS
181 
182  private:
183  // the record counter used to parse the apriori database
184  RecordCounter< ALLOC > __counter;
185 
186  // the internal weight is equal to _weight / nb rows of apriori database
187  // this internal weight is used to ensure that assigning a weight of 1
188  // to the apriori is equivalent to adding just one row to the learning
189  // database
190  double __internal_weight;
191 
192 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
193  };
194 
195  } /* namespace learning */
196 
197 } /* namespace gum */
198 
201 
202 #endif /* GUM_LEARNING_A_PRIORI_DIRICHLET_FROM_DATABASE_H */
virtual bool isOfType(const std::string &type) final
indicates whether an apriori is of a certain type
virtual AprioriDirichletFromDatabase< ALLOC > * clone() const
virtual copy constructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
STL namespace.
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set...
Definition: idSet.h:48
the base class for all a priori
Definition: apriori.h:50
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual bool isInformative() const final
indicates whether the apriori is potentially informative
A dirichlet priori: computes its N&#39;_ijk from a database.
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.
The class that computes countings of observations from the database.
virtual void setWeight(const double weight) final
sets the weight of the a priori (kind of effective sample size)
double weight() const
returns the weight assigned to the apriori
virtual void addConditioningApriori(const IdSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts) final
adds the apriori to a counting vectordefined over the right hand side of the idset ...
virtual ~AprioriDirichletFromDatabase()
destructor
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
AprioriDirichletFromDatabase(const DatabaseTable< ALLOC > &learning_db, const DBRowGeneratorParser< ALLOC > &apriori_parser, 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
The class representing a tabular database as used by learning tasks.
virtual const std::string & getType() const final
returns the type of the apriori
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: apriori.h:53
virtual void addAllApriori(const IdSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts) final
adds the apriori to a counting vector corresponding to the idset
the class used to read a row in the database and to transform it into a set of DBRow instances that c...
Size NodeId
Type for node ids.
Definition: graphElements.h:98
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
AprioriDirichletFromDatabase< ALLOC > & operator=(const AprioriDirichletFromDatabase< ALLOC > &from)
copy operator