aGrUM  0.16.0
scoreK2.h
Go to the documentation of this file.
1 
32 #ifndef GUM_LEARNING_SCORE_K2_H
33 #define GUM_LEARNING_SCORE_K2_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 
60  template < template < typename > class ALLOC = std::allocator >
61  class ScoreK2 : public Score< ALLOC > {
62  public:
64  using allocator_type = ALLOC< NodeId >;
65 
66  // ##########################################################################
68  // ##########################################################################
70 
72 
93  const Apriori< ALLOC >& apriori,
94  const std::vector< std::pair< std::size_t, std::size_t >,
95  ALLOC< std::pair< std::size_t, std::size_t > > >&
96  ranges,
97  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
98  nodeId2columns =
99  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
100  const allocator_type& alloc = allocator_type());
101 
102 
104 
119  const Apriori< ALLOC >& apriori,
120  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
121  nodeId2columns =
122  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
123  const allocator_type& alloc = allocator_type());
124 
126  ScoreK2(const ScoreK2< ALLOC >& from);
127 
129  ScoreK2(const ScoreK2< ALLOC >& from, const allocator_type& alloc);
130 
132  ScoreK2(ScoreK2< ALLOC >&& from);
133 
135  ScoreK2(ScoreK2< ALLOC >&& from, const allocator_type& alloc);
136 
138  virtual ScoreK2< ALLOC >* clone() const;
139 
141  virtual ScoreK2< ALLOC >* clone(const allocator_type& alloc) const;
142 
144  virtual ~ScoreK2();
145 
147 
148 
149  // ##########################################################################
151  // ##########################################################################
152 
154 
157 
160 
162 
163 
164  // ##########################################################################
166  // ##########################################################################
168 
170 
179  virtual std::string isAprioriCompatible() const final;
180 
182 
192  virtual const Apriori< ALLOC >& internalApriori() const final;
193 
195 
196 
198 
200  static std::string isAprioriCompatible(const std::string& apriori_type,
201  double weight = 1.0f);
202 
204 
205  static std::string isAprioriCompatible(const Apriori< ALLOC >& apriori);
206 
207 
208  protected:
210 
213  virtual double _score(const IdSet< ALLOC >& idset) final;
214 
215 
216 #ifndef DOXYGEN_SHOULD_SKIP_THIS
217 
218  private:
220  AprioriK2< ALLOC > __internal_apriori;
221 
223  GammaLog2 __gammalog2;
224 
225 
226 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
227  };
228 
229  } /* namespace learning */
230 
231 } /* namespace gum */
232 
233 
234 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
235 extern template class gum::learning::ScoreK2<>;
236 #endif
237 
238 
239 // always include the template implementation
241 
242 #endif /* GUM_LEARNING_SCORE_K2_H */
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for computing Log2 (Gamma(x))
Definition: gammaLog2.h:48
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.
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.
the class for computing K2 scores (actually their log2 value)
Definition: scoreK2.h:61
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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
ScoreK2< ALLOC > & operator=(const ScoreK2< ALLOC > &from)
copy operator
virtual ScoreK2< ALLOC > * clone() const
virtual copy constructor
ScoreK2(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
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.
virtual const Apriori< ALLOC > & internalApriori() const final
returns the internal apriori of the score
virtual std::string isAprioriCompatible() const final
indicates whether the apriori is compatible (meaningful) with the score
the internal apriori for the K2 score = Laplace AprioriK2 is a BD score with a Laplace apriori (i...
Definition: aprioriK2.h:52
virtual double _score(const IdSet< ALLOC > &idset) final
returns the score for a given IdSet
virtual ~ScoreK2()
destructor
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
Definition: scoreK2.h:64