aGrUM  0.14.2
scorefNML.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  ***************************************************************************/
26 #ifndef GUM_LEARNING_SCORE_FNML_H
27 #define GUM_LEARNING_SCORE_FNML_H
28 
29 #include <string>
30 
31 #include <agrum/agrum.h>
32 #include <agrum/core/math/math.h>
36 
37 namespace gum {
38 
39  namespace learning {
40 
41 
50  template < template < typename > class ALLOC = std::allocator >
51  class ScorefNML : public Score< ALLOC > {
52  public:
54  using allocator_type = ALLOC< NodeId >;
55 
56  // ##########################################################################
58  // ##########################################################################
60 
62 
82  ScorefNML(
83  const DBRowGeneratorParser< ALLOC >& parser,
84  const Apriori< ALLOC >& apriori,
85  const std::vector< std::pair< std::size_t, std::size_t >,
86  ALLOC< std::pair< std::size_t, std::size_t > > >&
87  ranges,
88  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
89  nodeId2columns =
90  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
91  const allocator_type& alloc = allocator_type());
92 
93 
95 
110  const Apriori< ALLOC >& apriori,
111  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
112  nodeId2columns =
113  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
114  const allocator_type& alloc = allocator_type());
115 
117  ScorefNML(const ScorefNML< ALLOC >& from);
118 
120  ScorefNML(const ScorefNML< ALLOC >& from, const allocator_type& alloc);
121 
124 
126  ScorefNML(ScorefNML< ALLOC >&& from, const allocator_type& alloc);
127 
129  virtual ScorefNML< ALLOC >* clone() const;
130 
132  virtual ScorefNML< ALLOC >* clone(const allocator_type& alloc) const;
133 
135  virtual ~ScorefNML();
136 
138 
139 
140  // ##########################################################################
142  // ##########################################################################
143 
145 
148 
151 
153 
154 
155  // ##########################################################################
157  // ##########################################################################
159 
161 
170  virtual std::string isAprioriCompatible() const final;
171 
173 
183  virtual const Apriori< ALLOC >& internalApriori() const final;
184 
186 
187 
189 
191  static std::string isAprioriCompatible(const std::string& apriori_type,
192  double weight = 1.0f);
193 
195 
196  static std::string isAprioriCompatible(const Apriori< ALLOC >& apriori);
197 
198 
199  protected:
201 
204  virtual double _score(const IdSet< ALLOC >& idset) final;
205 
206 
207 #ifndef DOXYGEN_SHOULD_SKIP_THIS
208 
209  private:
211  AprioriNoApriori< ALLOC > __internal_apriori;
212 
215 
216 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
217  };
218 
219 
220  } /* namespace learning */
221 
222 
223 } /* namespace gum */
224 
225 
226 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
227 extern template class gum::learning::ScorefNML<>;
228 #endif
229 
230 
231 // always include the template implementation
233 
234 #endif /* GUM_LEARNING_SCORE_FNML_H */
Useful macros for maths.
virtual std::string isAprioriCompatible() const final
indicates whether the apriori is compatible (meaningful) with the score
The base class for all the scores used for learning (BIC, BDeu, etc)
Definition: score.h:49
virtual ScorefNML< ALLOC > * clone() const
virtual copy constructor
the no a priori class: corresponds to 0 weight-sample
the class for computing fNML scores
STL namespace.
virtual ~ScorefNML()
destructor
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
virtual const Apriori< ALLOC > & internalApriori() const final
returns the internal apriori of the score
ScorefNML(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
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: score.h:52
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
the class for computing the log2 of the parametric complexity of an r-ary multinomial variable ...
the class for computing fNML scores
Definition: scorefNML.h:51
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
ScorefNML< ALLOC > & operator=(const ScorefNML< ALLOC > &from)
copy operator
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: scorefNML.h:54
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1803
virtual double _score(const IdSet< ALLOC > &idset) final
returns the score for a given IdSet
the base class for all the scores used for learning (BIC, BDeu, etc)
the class for computing the log2 of the parametric complexity of an r-ary multinomial variableThis cl...
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:97
the no a priori class: corresponds to 0 weight-sample