aGrUM  0.16.0
scoreBDeu.h
Go to the documentation of this file.
1 
29 #ifndef GUM_LEARNING_SCORE_BDEU_H
30 #define GUM_LEARNING_SCORE_BDEU_H
31 
32 #include <string>
33 
34 #include <agrum/agrum.h>
35 #include <agrum/core/math/math.h>
39 
40 namespace gum {
41 
42  namespace learning {
43 
58  template < template < typename > class ALLOC = std::allocator >
59  class ScoreBDeu : public Score< ALLOC > {
60  public:
62  using allocator_type = ALLOC< NodeId >;
63 
64  // ##########################################################################
66  // ##########################################################################
68 
70 
90  ScoreBDeu(
91  const DBRowGeneratorParser< ALLOC >& parser,
92  const Apriori< ALLOC >& apriori,
93  const std::vector< std::pair< std::size_t, std::size_t >,
94  ALLOC< std::pair< std::size_t, std::size_t > > >&
95  ranges,
96  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
97  nodeId2columns =
98  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
99  const allocator_type& alloc = allocator_type());
100 
101 
103 
118  const Apriori< ALLOC >& apriori,
119  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
120  nodeId2columns =
121  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
122  const allocator_type& alloc = allocator_type());
123 
125  ScoreBDeu(const ScoreBDeu< ALLOC >& from);
126 
128  ScoreBDeu(const ScoreBDeu< ALLOC >& from, const allocator_type& alloc);
129 
132 
134  ScoreBDeu(ScoreBDeu< ALLOC >&& from, const allocator_type& alloc);
135 
137  virtual ScoreBDeu< ALLOC >* clone() const;
138 
140  virtual ScoreBDeu< ALLOC >* clone(const allocator_type& alloc) const;
141 
143  virtual ~ScoreBDeu();
144 
146 
147 
148  // ##########################################################################
150  // ##########################################################################
151 
153 
156 
159 
161 
162 
163  // ##########################################################################
165  // ##########################################################################
167 
169 
178  virtual std::string isAprioriCompatible() const final;
179 
181 
191  virtual const Apriori< ALLOC >& internalApriori() const final;
192 
194  void setEffectiveSampleSize(double ess);
195 
197 
198 
200 
202  static std::string isAprioriCompatible(const std::string& apriori_type,
203  double weight = 1.0f);
204 
206 
207  static std::string isAprioriCompatible(const Apriori< ALLOC >& apriori);
208 
209 
210  protected:
212 
215  virtual double _score(const IdSet< ALLOC >& idset) final;
216 
217 
218 #ifndef DOXYGEN_SHOULD_SKIP_THIS
219 
220  private:
222  AprioriBDeu< ALLOC > __internal_apriori;
223 
225  GammaLog2 __gammalog2;
226 
227 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
228  };
229 
230  } /* namespace learning */
231 
232 } /* namespace gum */
233 
234 
235 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
236 extern template class gum::learning::ScoreBDeu<>;
237 #endif
238 
239 
240 // always include the template implementation
242 
243 #endif /* GUM_LEARNING_SCORE_BDEU_H */
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.
virtual ScoreBDeu< ALLOC > * clone() const
virtual copy constructor
The class for computing Log2 (Gamma(x))
Definition: gammaLog2.h:48
the class for computing BDeu scores
Definition: scoreBDeu.h:59
virtual const Apriori< ALLOC > & internalApriori() const final
returns the internal apriori of the score
The base class for all the scores used for learning (BIC, BDeu, etc)
Definition: score.h:52
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: scoreBDeu.h:62
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 ~ScoreBDeu()
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
the internal apriori for the BDeu score (N&#39; / (r_i * q_i)BDeu is a BD score with a N&#39;/(r_i * q_i) apr...
Definition: aprioriBDeu.h:54
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
void setEffectiveSampleSize(double ess)
sets the effective sample size of the internal apriori
virtual double _score(const IdSet< ALLOC > &idset) final
returns the score for a given IdSet
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.
ScoreBDeu< ALLOC > & operator=(const ScoreBDeu< ALLOC > &from)
copy operator
ScoreBDeu(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
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.