aGrUM  0.16.0
apriori.h
Go to the documentation of this file.
1 
28 #ifndef GUM_LEARNING_A_PRIORI_H
29 #define GUM_LEARNING_A_PRIORI_H
30 
31 #include <string>
32 #include <vector>
33 
34 #include <agrum/agrum.h>
35 #include <agrum/core/bijection.h>
39 
40 namespace gum {
41 
42  namespace learning {
43 
49  template < template < typename > class ALLOC = std::allocator >
50  class Apriori : private ALLOC< NodeId > {
51  public:
53  using allocator_type = ALLOC< NodeId >;
54 
55  // ##########################################################################
57  // ##########################################################################
59 
61 
72  Apriori(const DatabaseTable< ALLOC >& database,
73  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
74  nodeId2columns =
75  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
76  const allocator_type& alloc = allocator_type());
77 
79  virtual Apriori< ALLOC >* clone() const = 0;
80 
82  virtual Apriori< ALLOC >* clone(const allocator_type& alloc) const = 0;
83 
85  virtual ~Apriori();
86 
88 
89  // ##########################################################################
91  // ##########################################################################
93 
95  virtual void setWeight(const double weight);
96 
98  double weight() const;
99 
101  virtual bool isOfType(const std::string& type) = 0;
102 
104  virtual const std::string& getType() const = 0;
105 
107 
114  virtual bool isInformative() const = 0;
115 
117 
122  virtual void
123  addAllApriori(const IdSet< ALLOC >& idset,
124  std::vector< double, ALLOC< double > >& counts) = 0;
125 
131  virtual void addConditioningApriori(
132  const IdSet< ALLOC >& idset,
133  std::vector< double, ALLOC< double > >& counts) = 0;
134 
137 
139 
140 
141  protected:
143  double _weight{1.0};
144 
147 
151 
152 
154  Apriori(const Apriori< ALLOC >& from);
155 
157  Apriori(const Apriori< ALLOC >& from, const allocator_type& alloc);
158 
160  Apriori(Apriori< ALLOC >&& from);
161 
163  Apriori(Apriori< ALLOC >&& from, const allocator_type& alloc);
164 
167 
170  };
171 
172  } /* namespace learning */
173 
174 } /* namespace gum */
175 
178 
179 #endif /* GUM_LEARNING_A_PRIORI_H */
virtual void setWeight(const double weight)
sets the weight of the a priori (kind of effective sample size)
virtual const std::string & getType() const =0
returns the type of the apriori
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 bool isOfType(const std::string &type)=0
indicates whether an apriori is of a certain type
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 void addConditioningApriori(const IdSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts)=0
adds the apriori to a counting vectordefined over the right hand side of the idset ...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
const DatabaseTable< ALLOC > * _database
a reference to the database in order to have access to its variables
Definition: apriori.h:146
virtual Apriori< ALLOC > * clone() const =0
virtual copy constructor
virtual void addAllApriori(const IdSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts)=0
adds the apriori to a counting vector corresponding to the idset
double weight() const
returns the weight assigned to the apriori
double _weight
the weight of the apriori
Definition: apriori.h:143
Apriori< ALLOC > & operator=(const Apriori< ALLOC > &from)
copy operator
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class representing a tabular database as used by learning tasks.
virtual bool isInformative() const =0
indicates whether the apriori is potentially informative
allocator_type getAllocator() const
returns the allocator used by the internal apriori
Bijection< NodeId, std::size_t, ALLOC< std::size_t > > _nodeId2columns
a mapping from the NodeIds of the variables to the indices of the columns in the database ...
Definition: apriori.h:150
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: apriori.h:53
Size NodeId
Type for node ids.
Definition: graphElements.h:98
Apriori(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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual ~Apriori()
destructor