aGrUM  0.14.2
aprioriBDeu.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
25 #ifndef GUM_LEARNING_A_PRIORI_BDEU_H
26 #define GUM_LEARNING_A_PRIORI_BDEU_H
27 
28 #include <vector>
29 
30 #include <agrum/agrum.h>
32 
33 namespace gum {
34 
35  namespace learning {
36 
50  template < template < typename > class ALLOC = std::allocator >
51  class AprioriBDeu : public Apriori< ALLOC > {
52  public:
55 
57  using allocator_type = ALLOC< NodeId >;
58 
59 
60  // ##########################################################################
62  // ##########################################################################
64 
66 
77  AprioriBDeu(const DatabaseTable< ALLOC >& database,
78  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
79  nodeId2columns =
80  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
81  const allocator_type& alloc = allocator_type());
82 
84  AprioriBDeu(const AprioriBDeu< ALLOC >& from);
85 
87  AprioriBDeu(const AprioriBDeu< ALLOC >& from, const allocator_type& alloc);
88 
91 
93  AprioriBDeu(AprioriBDeu< ALLOC >&& from, const allocator_type& alloc);
94 
96  virtual AprioriBDeu< ALLOC >* clone() const;
97 
99  virtual AprioriBDeu< ALLOC >* clone(const allocator_type& alloc) const;
100 
102  virtual ~AprioriBDeu();
103 
105 
106 
107  // ##########################################################################
109  // ##########################################################################
111 
114 
117 
119 
120 
121  // ##########################################################################
123  // ##########################################################################
125 
127  virtual void setWeight(const double weight) final;
128 
130  void setEffectiveSampleSize(const double weight);
131 
133  virtual bool isOfType(const std::string& type) final;
134 
136  virtual const std::string& getType() const final;
137 
139 
146  virtual bool isInformative() const final;
147 
149 
154  virtual void
155  addAllApriori(const IdSet< ALLOC >& idset,
156  std::vector< double, ALLOC< double > >& counts) final;
157 
163  virtual void addConditioningApriori(
164  const IdSet< ALLOC >& idset,
165  std::vector< double, ALLOC< double > >& counts) final;
166 
168  };
169 
170  } /* namespace learning */
171 
172 } /* namespace gum */
173 
175 #include <agrum/learning/aprioris/aprioriBDeu_tpl.h>
176 
177 #endif /* GUM_LEARNING_A_PRIORI_BDEU_H */
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 AprioriBDeu< ALLOC > * clone() const
virtual copy constructor
AprioriBDeu< ALLOC > & operator=(const AprioriBDeu< ALLOC > &from)
copy operator
virtual ~AprioriBDeu()
destructor
virtual const std::string & getType() const final
returns the type of the apriori
the base class for all a priori
STL namespace.
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set...
Definition: idSet.h:45
the base class for all a priori
Definition: apriori.h:47
gum is the global namespace for all aGrUM entities
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:51
virtual void setWeight(const double weight) final
sets the effective sample size N&#39; (alias of setEffectiveSampleSize ())
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
double weight() const
returns the weight assigned to the apriori
virtual bool isInformative() const final
indicates whether the apriori is potentially informative
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1803
The class representing a tabular database as used by learning tasks.
virtual bool isOfType(const std::string &type) final
indicates whether an apriori is of a certain type
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: aprioriBDeu.h:57
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: apriori.h:50
Size NodeId
Type for node ids.
Definition: graphElements.h:97
AprioriBDeu(const DatabaseTable< ALLOC > &database, 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
void setEffectiveSampleSize(const double weight)
sets the effective sample size N&#39;