aGrUM  0.16.0
indepTestChi2.h
Go to the documentation of this file.
1 
29 #ifndef GUM_LEARNING_INDEP_TEST_CHI2_H
30 #define GUM_LEARNING_INDEP_TEST_CHI2_H
31 
32 #include <vector>
33 
34 #include <agrum/core/math/chi2.h>
37 
38 namespace gum {
39 
40  namespace learning {
41 
47  template < template < typename > class ALLOC = std::allocator >
48  class IndepTestChi2 : 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 
117 
120  const allocator_type& alloc);
121 
124 
127 
129  virtual IndepTestChi2< ALLOC >* clone() const;
130 
132  virtual IndepTestChi2< ALLOC >* clone(const allocator_type& alloc) const;
133 
135  virtual ~IndepTestChi2();
136 
138 
139 
140  // ##########################################################################
142  // ##########################################################################
143 
145 
148 
151 
153 
154  // ##########################################################################
156  // ##########################################################################
157 
159 
162  std::pair< double, double >
163  statistics(NodeId var1,
164  NodeId var2,
165  const std::vector< NodeId, ALLOC< NodeId > >& rhs_ids = {});
166 
168 
169 
170  protected:
172 
175  virtual double _score(const IdSet< ALLOC >& idset) final;
176 
178  std::pair< double, double > _statistics(const IdSet< ALLOC >& idset);
179 
180 #ifndef DOXYGEN_SHOULD_SKIP_THIS
181 
182  private:
184  std::vector< std::size_t, ALLOC< std::size_t > > __domain_sizes;
185 
187  Chi2 __chi2;
188 
190  const std::vector< Idx > __empty_set;
191 
192 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
193  };
194 
195  } /* namespace learning */
196 
197 } /* namespace gum */
198 
199 
200 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
201 extern template class gum::learning::IndepTestChi2<>;
202 #endif
203 
204 
205 // always include the template implementation
207 
208 #endif /* GUM_LEARNING_INDEP_TEST_CHI2_H */
std::pair< double, double > _statistics(const IdSet< ALLOC > &idset)
compute the pair <chi2 statistic,pvalue>
virtual IndepTestChi2< ALLOC > * clone() const
virtual copy constructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Definition: indepTestChi2.h:51
The base class for all the independence tests used for learning.
IndepTestChi2(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
IndepTestChi2< ALLOC > & operator=(const IndepTestChi2< ALLOC > &from)
copy operator
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
the class for computing Chi2 independence test scores
Definition: indepTestChi2.h:48
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::pair< double, double > statistics(NodeId var1, NodeId var2, const std::vector< NodeId, ALLOC< NodeId > > &rhs_ids={})
get the pair <chi2 statistic,pvalue> for a test var1 indep var2 given rhs_ids
Represent the chi2 distribution.
Definition: chi2.h:58
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 double _score(const IdSet< ALLOC > &idset) final
returns the score for a given IdSet
virtual ~IndepTestChi2()
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