aGrUM  0.16.0
scoreBD.h
Go to the documentation of this file.
1 
32 #ifndef GUM_LEARNING_SCORE_BD_H
33 #define GUM_LEARNING_SCORE_BD_H
34 
35 #include <string>
36 
37 #include <agrum/agrum.h>
38 #include <agrum/core/math/math.h>
42 
43 namespace gum {
44 
45  namespace learning {
46 
64  template < template < typename > class ALLOC = std::allocator >
65  class ScoreBD : public Score< ALLOC > {
66  public:
68  using allocator_type = ALLOC< NodeId >;
69 
70  // ##########################################################################
72  // ##########################################################################
74 
76 
97  const Apriori< ALLOC >& apriori,
98  const std::vector< std::pair< std::size_t, std::size_t >,
99  ALLOC< std::pair< std::size_t, std::size_t > > >&
100  ranges,
101  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
102  nodeId2columns =
103  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
104  const allocator_type& alloc = allocator_type());
105 
106 
108 
123  const Apriori< ALLOC >& apriori,
124  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
125  nodeId2columns =
126  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
127  const allocator_type& alloc = allocator_type());
128 
130  ScoreBD(const ScoreBD< ALLOC >& from);
131 
133  ScoreBD(const ScoreBD< ALLOC >& from, const allocator_type& alloc);
134 
136  ScoreBD(ScoreBD< ALLOC >&& from);
137 
139  ScoreBD(ScoreBD< ALLOC >&& from, const allocator_type& alloc);
140 
142  virtual ScoreBD< ALLOC >* clone() const;
143 
145  virtual ScoreBD< ALLOC >* clone(const allocator_type& alloc) const;
146 
148  virtual ~ScoreBD();
149 
151 
152 
153  // ##########################################################################
155  // ##########################################################################
156 
158 
161 
164 
166 
167 
168  // ##########################################################################
170  // ##########################################################################
172 
174 
183  virtual std::string isAprioriCompatible() const final;
184 
186 
196  virtual const Apriori< ALLOC >& internalApriori() const final;
197 
199 
200 
202 
204  static std::string isAprioriCompatible(const std::string& apriori_type,
205  double weight = 1.0f);
206 
208 
209  static std::string isAprioriCompatible(const Apriori< ALLOC >& apriori);
210 
211 
212  protected:
214 
217  virtual double _score(const IdSet< ALLOC >& idset) final;
218 
219 
220 #ifndef DOXYGEN_SHOULD_SKIP_THIS
221 
222  private:
224  AprioriNoApriori< ALLOC > __internal_apriori;
225 
227  GammaLog2 __gammalog2;
228 
229 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
230  };
231 
232  } /* namespace learning */
233 
234 } /* namespace gum */
235 
236 
237 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
238 extern template class gum::learning::ScoreBD<>;
239 #endif
240 
241 
242 // always include the template implementation
244 
245 #endif /* GUM_LEARNING_SCORE_BD_H */
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual const Apriori< ALLOC > & internalApriori() const final
returns the internal apriori of the score
The class for computing Log2 (Gamma(x))
Definition: gammaLog2.h:48
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: scoreBD.h:68
The base class for all the scores used for learning (BIC, BDeu, etc)
Definition: score.h:52
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
the class for computing Bayesian Dirichlet (BD) log2 scores
Definition: scoreBD.h:65
ScoreBD(const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &apriori, const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > &ranges, 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
virtual double _score(const IdSet< ALLOC > &idset) final
returns the score for a given IdSet
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.
virtual ~ScoreBD()
destructor
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: score.h:55
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > & ranges() const
returns the current ranges
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
ScoreBD< ALLOC > & operator=(const ScoreBD< ALLOC > &from)
copy operator
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
virtual std::string isAprioriCompatible() const final
indicates whether the apriori is compatible (meaningful) with the score
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual ScoreBD< ALLOC > * clone() const
virtual copy constructor
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
the no a priori class: corresponds to 0 weight-sample