the class for computing G2 independence test scores
The class should be used as follows: first, to speedup computations,
you should consider computing all the independence tests you need in one
pass.
More...
#include <agrum/learning/scores_and_tests/indepTestG2.h>


template<typename RowFilter > 
 IndepTestG2 (const RowFilter &filter, const std::vector< Size > &var_modalities) 
 default constructor More...


 ~IndepTestG2 () 
 destructor More...



double  score (Idx nodeset_index) 
 returns the score corresponding to a given nodeset More...



Idx  addNodeSet (Idx var1, Idx var2) 
 add a new target node conditioned by another node to be counted More...


Idx  addNodeSet (const std::pair< Idx, Idx > &vars) 
 add a new target node conditioned by another node to be counted More...


Idx  addNodeSet (Idx var1, Idx var2, const std::vector< Idx > &conditioning_ids) 
 add a target conditioned by other variables to be counted More...


Idx  addNodeSet (Idx var1, Idx var2, std::vector< Idx > &&conditioning_ids) 
 add a target conditioned by other variables to be counted More...


Idx  addNodeSet (const std::pair< Idx, Idx > &vars, const std::vector< Idx > &conditioning_ids) 
 add a target conditioned by other variables to be counted More...


Idx  addNodeSet (const std::pair< Idx, Idx > &vars, std::vector< Idx > &&conditioning_ids) 
 add a target conditioned by other variables to be counted More...


void  clear () 
 clears all the data structures from memory More...


void  clearCache () 
 clears the current cache (clear nodesets as well) More...


void  useCache (bool on_off) noexcept 
 turn on/off the use of a cache of the previously computed score More...


template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
class gum::learning::IndepTestG2< IdSetAlloc, CountAlloc >
the class for computing G2 independence test scores
The class should be used as follows: first, to speedup computations,
you should consider computing all the independence tests you need in one
pass.
To do so, use the appropriate addNodeSet methods. These will compute everything you need. Use method score to retrieve the scores related to the independence test that were computed. See the IndependenceTest class for details.
Definition at line 64 of file indepTestG2.h.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
template<typename RowFilter >
default constructor
 Parameters

filter  the row filter that will be used to read the database 
var_modalities  the domain sizes of the variables in the database 
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>

protectednoexceptinherited 
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
inserts a new score into the cache
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>

protectednoexceptinherited 
indicates whether a score belongs to the cache
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>

protectednoexceptinherited 
indicates whether we use the cache or not
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
add a new target node conditioned by another node to be counted
 Parameters

var1  represents the index of the target variable in the filtered rows produced by the database cell filters 
var2  represents the index of the conditioning variable in the filtered rows produced by the database cell filters 
 Returns
 the index of the produced counting vector: the user should use class IndependenceTest to compute in one pass several independence tests. These and their corresponding countings in the database are stored into a vector and the value returned by method addNodeSet is the index of the counts in this vector. The user shall pass this index as argument to methods _getAllCounts and _getConditioningCounts to get the observed countings of (var2,var1) [in this order] and var2 respectively.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
add a new target node conditioned by another node to be counted
 Parameters

vars  contains the index of the target variable (first) in the filtered rows produced by the database cell filters, and the index of the conditioning variable (second). 
 Returns
 the index of the produced counting vector: the user should use class IndependenceTest to compute in one pass several independence tests. These and their corresponding countings in the database are stored into a vector and the value returned by method addNodeSet is the index of the counts in this vector. The user shall pass this index as argument to methods _getAllCounts and _getConditioningCounts to get the observed countings of (vars.second, vars.first) [in this order] and vars.second respectively.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
add a target conditioned by other variables to be counted
 Parameters

var1  represents the index of the target variable in the filtered rows produced by the database cell filters 
var2  represents the index of the last conditioning variable in the filtered rows produced by the database cell filters 
conditioning_ids  the indices of the variables of the conditioning set in the filtered rows (minus var2, which is subsequently apended to it). 
 Returns
 the index of the produced counting vector: the user should use class IndependenceTest to compute in one pass several independence tests. These and their corresponding countings in the database are stored into a vector and the value returned by method addNodeSet is the index of the counts in this vector. The user shall pass this index as argument to methods _getAllCounts and _getConditioningCounts to get the countings of (conditioning_ids, var2, var1) [in this order] and (conditioning_ids, var2) [in this order] respectively.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
add a target conditioned by other variables to be counted
 Parameters

var1  represents the index of the target variable in the filtered rows produced by the database cell filters 
var2  represents the index of the last conditioning variable in the filtered rows produced by the database cell filters 
conditioning_ids  the indices of the variables of the conditioning set in the filtered rows (minus var2, which is subsequently apended to it). 
 Returns
 the index of the produced counting vector: the user should use class IndependenceTest to compute in one pass several independence tests. These and their corresponding countings in the database are stored into a vector and the value returned by method addNodeSet is the index of the counts in this vector. The user shall pass this index as argument to methods _getAllCounts and _getConditioningCounts to get the countings of (conditioning_ids, var2, var1) [in this order] and (conditioning_ids, var2) [in this order] respectively.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
add a target conditioned by other variables to be counted
 Parameters

vars  represents the index of the target variable (first) in the filtered rows produced by the database cell filters, and the index of the last conditioning variable (second) 
conditioning_ids  the indices of the variables of the conditioning set in the filtered rows (minus vars.second which is appended to it) 
 Returns
 the index of the produced counting vector: the user should use class IndependenceTest to compute in one pass several independence tests. These and their corresponding countings in the database are stored into a vector and the value returned by method addNodeSet is the index of the counts in this vector. The user shall pass this index as argument to methods _getAllCounts and _getConditioningCounts to get the observed countings of (conditioning_ids, vars.second, vars.first) [in this order] and (conditioning_ids, vars.second) [in this order] respectively.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
add a target conditioned by other variables to be counted
 Parameters

vars  represents the index of the target variable (first) in the filtered rows produced by the database cell filters, and the index of the last conditioning variable (second) 
conditioning_ids  the indices of the variables of the conditioning set in the filtered rows (minus vars.second which is appended to it) 
 Returns
 the index of the produced counting vector: the user should use class IndependenceTest to compute in one pass several independence tests. These and their corresponding countings in the database are stored into a vector and the value returned by method addNodeSet is the index of the counts in this vector. The user shall pass this index as argument to methods _getAllCounts and _getConditioningCounts to get the observed countings of (conditioning_ids, vars.second, vars.first) [in this order] and (conditioning_ids, vars.second) [in this order] respectively.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
clears all the data structures from memory
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
clears the current cache (clear nodesets as well)
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
returns the score corresponding to a given nodeset
This method computes sum_X sum_Y sum_Z #XYZ * log ( ( #XYZ * #Z ) / ( #XZ * #YZ ) ), where #XYZ, #XZ, #YZ, #Z correspond to the number of occurences of (X,Y,Z), (X,Z), (Y,Z) and Z respectively in the database. Then, it computes the critical value alpha for the chi2 test and returns ( #sum  alpha ) / alpha, where #sum corresponds to the summations mentioned above. Therefore, any positive result should reflect a dependence whereas negative results should reflect independences.
Implements gum::learning::IndependenceTest< IdSetAlloc, CountAlloc >.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
turn on/off the use of a cache of the previously computed score
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
a chi2 distribution for computing critical values
Definition at line 104 of file indepTestG2.h.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
The documentation for this class was generated from the following file: