aGrUM  0.16.0
indepTestG2.h
Go to the documentation of this file.
1 
29 #ifndef GUM_LEARNING_INDEP_TEST_G2_H
30 #define GUM_LEARNING_INDEP_TEST_G2_H
31 
32 #include <agrum/core/math/chi2.h>
35 
36 namespace gum {
37 
38  namespace learning {
39 
46  // clang-format on
47  template < template < typename > class ALLOC = std::allocator >
48  class IndepTestG2 : public IndependenceTest< ALLOC > {
49  public:
51  using allocator_type = ALLOC< NodeId >;
52 
53  // ##########################################################################
55  // ##########################################################################
57 
59 
82  const DBRowGeneratorParser< ALLOC >& parser,
83  const Apriori< ALLOC >& external_apriori,
84  const std::vector< std::pair< std::size_t, std::size_t >,
85  ALLOC< std::pair< std::size_t, std::size_t > > >&
86  ranges,
87  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
88  nodeId2columns =
89  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
90  const allocator_type& alloc = allocator_type());
91 
92 
94 
109  const Apriori< ALLOC >& apriori,
110  const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >&
111  nodeId2columns =
112  Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(),
113  const allocator_type& alloc = allocator_type());
114 
116  IndepTestG2(const IndepTestG2< ALLOC >& from);
117 
119  IndepTestG2(const IndepTestG2< ALLOC >& from, const allocator_type& alloc);
120 
123 
125  IndepTestG2(IndepTestG2< ALLOC >&& from, const allocator_type& alloc);
126 
128  virtual IndepTestG2< ALLOC >* clone() const;
129 
131  virtual IndepTestG2< ALLOC >* clone(const allocator_type& alloc) const;
132 
134  virtual ~IndepTestG2();
135 
137 
138 
139  // ##########################################################################
141  // ##########################################################################
142 
144 
147 
150 
153  std::pair< double, double >
154  statistics(NodeId var1,
155  NodeId var2,
156  const std::vector< NodeId, ALLOC< NodeId > >& rhs_ids = {});
157 
159 
160 
161  protected:
163 
166  virtual double _score(const IdSet< ALLOC >& idset) final;
167 
169  std::pair< double, double > _statistics(const IdSet< ALLOC >& idset);
170 
171 #ifndef DOXYGEN_SHOULD_SKIP_THIS
172 
173  private:
175  std::vector< std::size_t, ALLOC< std::size_t > > __domain_sizes;
176 
178  Chi2 __chi2;
179 
181  const std::vector< Idx > __empty_set;
182 
183 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
184  };
185 
186  } /* namespace learning */
187 
188 } /* namespace gum */
189 
190 
191 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
192 extern template class gum::learning::IndepTestG2<>;
193 #endif
194 
195 
196 // always include the template implementation
198 
199 #endif /* GUM_LEARNING_INDEP_TEST_G2_H */
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: indepTestG2.h:51
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The base class for all the independence tests used for learning.
virtual IndepTestG2< ALLOC > * clone() const
virtual copy constructor
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
IndepTestG2(const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &external_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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
the class for computing G2 independence test scores
Definition: indepTestG2.h:48
Represent the chi2 distribution.
Definition: chi2.h:58
std::pair< double, double > statistics(NodeId var1, NodeId var2, const std::vector< NodeId, ALLOC< NodeId > > &rhs_ids={})
get the pair <G2statistic,pvalue> for a test var1 indep var2 given rhs_ids
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual ~IndepTestG2()
destructor
IndepTestG2< ALLOC > & operator=(const IndepTestG2< ALLOC > &from)
copy operator
virtual double _score(const IdSet< ALLOC > &idset) final
returns the score for a given IdSet
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
std::pair< double, double > _statistics(const IdSet< ALLOC > &idset)
compute the pair <G2 statistic,pvalue>